Listbox.Text to integer value 
Author Message
 Listbox.Text to integer value

I have to check to see if a selected year value is a leap year or not.
To select the year, I have a list box with the current year (Year(Now))
and the next year.  I originally tried:
Yearl is my listbox:
If Int(Yearl.Text) Mod 4 = 0 Then
'leap year
End If

But that gives me a type mismatch error.  How can I convert the Text
from the list box to an integer value?  I also tried Cint but no luck
there.
Will I have to do it manually, ie: if Yearl.Text="97" Then Yr = 97?
Thanks,

Lance



Sun, 21 May 2000 03:00:00 GMT  
 Listbox.Text to integer value

On Wed, 03 Dec 1997 10:24:19 -0800, LM Robinson

Quote:

><I have to check to see if a selected year value is a leap year or not.
><To select the year, I have a list box with the current year (Year(Now))
><and the next year.  I originally tried:
><Yearl is my listbox:
><If Int(Yearl.Text) Mod 4 = 0 Then
><'leap year
><End If
><
><But that gives me a type mismatch error.  How can I convert the Text
><from the list box to an integer value?  I also tried Cint but no luck
><there.
><Will I have to do it manually, ie: if Yearl.Text="97" Then Yr = 97?
><Thanks,
><
><Lance

First of all, year 1900 is not a leap one, because a year ending with
"00" is only a leap one if Year Mod 400 = 0.

Secondly, the listbox DOES NOT have a Text property, it is List
indexed by the ListIndex. Get help on the listbox control.



Sun, 21 May 2000 03:00:00 GMT  
 Listbox.Text to integer value

Quote:

> First of all, year 1900 is not a leap one, because a year ending with
> "00" is only a leap one if Year Mod 400 = 0.

Thanks, I forgot about that!

Quote:
> Secondly, the listbox DOES NOT have a Text property, it is List
> indexed by the ListIndex. Get help on the listbox control.

I'm afraid I have to disagree with you here.  It does have a text
property, however it is read-only.  Code it and see.

Lance



Sun, 21 May 2000 03:00:00 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. Write contents of listbox to text file/populate listbox from text file

2. Listbox Item Text vs. Value

3. Usering script to display the contents(text,value) of the option of a html listbox

4. Populating listbox with values from a text file

5. VB3: Setting listbox based on value of other listbox

6. Combobox or Listbox: separting key values from display values

7. ListBox input as integer ?

8. How to Sort integer numbers inside listbox

9. Listbox Index limited to Integer

10. How to sort integer numbers inside Listbox control

11. How to sort integer numbers inside ListBox

12. Formatting an integer for a listbox

 

 
Powered by phpBB® Forum Software