Need help with Select Case...

meteo
02-16-2004, 10:02 AM
Well, I thought everything was going alright until I noticed my tickers/counters weren't updating correctly. Here's my code:

tcount = 8

Select Case Len(tcount)
Case "1"
frmBis.imgT4.Picture = LoadPicture(App.Path & "\Images\" & tcount & ".bmp")

Case "2"
intDigit1 = Left$(tcount, 1)
frmBis.imgT3.Picture = LoadPicture(App.Path & "\Images\" & intDigit1 & ".bmp")
frmBis.imgT4.Picture = LoadPicture(App.Path & "\Images\" & Right$(tcount, 1) & ".bmp")

Case "3"
intDigit2 = Left$(tcount, 1)
intDigit1 = Left$(tcount, 2)
intDigit1 = Right$(intDigit1, 1)
frmBis.imgT2.Picture = LoadPicture(App.Path & "\Images\" & intDigit2 & ".bmp")
frmBis.imgT3.Picture = LoadPicture(App.Path & "\Images\" & intDigit1 & ".bmp")
frmBis.imgT4.Picture = LoadPicture(App.Path & "\Images\" & Right$(tcount, 1) & ".bmp")
End Select


Now, the "tcount = 8" is NOT part of the code. It will always start out as "0" and then the code will do "tcount = tcount + 1". I just have it in there so that I can test high numbers without having to step through the code in order to increase the count.
Anyway, no matter what value I make tcount, the "Len(tcount)" will always return a 2. All the variables included (tcount, intDigit, etc) are stored as integers. My "ticker/counter" will allow up to 9999, though more than 99% of the time, numbers will not go above 250.
Does anyone know why this is not working? I could probably just set a new variable to store the length of tcount before I enter the Select Case, right? It would be something like this:

tcount = 8665

NewVar = Len(tcount)

Select Case NewVar
Case "1"
frmBis.imgT4.Picture = LoadPicture(App.Path & "\Images\" & tcount & ".bmp")

Case "2"
intDigit1 = Left$(tcount, 1)
frmBis.imgT3.Picture = LoadPicture(App.Path & "\Images\" & intDigit1 & ".bmp")
frmBis.imgT4.Picture = LoadPicture(App.Path & "\Images\" & Right$(tcount, 1) & ".bmp")

Case "3"
intDigit2 = Left$(tcount, 1)
intDigit1 = Left$(tcount, 2)
intDigit1 = Right$(intDigit1, 1)
frmBis.imgT2.Picture = LoadPicture(App.Path & "\Images\" & intDigit2 & ".bmp")
frmBis.imgT3.Picture = LoadPicture(App.Path & "\Images\" & intDigit1 & ".bmp")
frmBis.imgT4.Picture = LoadPicture(App.Path & "\Images\" & Right$(tcount, 1) & ".bmp")
End Select

Would this be better to do or does it really matter? If you need any more info, please let me know.

Thanks!

00100b
02-16-2004, 10:14 AM
The Len() of an Integer will always be two because an Integer is 2 bytes.

If you want to determine the Len() of an integer value as a string, then use something like:

NewVar = Len(Cstr(tcount))

Agent707
02-16-2004, 10:15 AM
Is tcount supposed to be a number "string"?

The Len() function is meant to return the "length" of a string.

ie. Len("Testing") returns 7

Is that what you mean to do here? :confused:

meteo
02-16-2004, 10:25 AM
00100b, that would be exactly what was needed. I never knew that Len was only for String variables. :o

Agent707, tcount is for an Integer (T is for total and count is, well, for count). I should have named it intTcount, but I got lazy when working this up late Friday night. Though I could have set the variables as strings and it all would have been fine, it seemed more proper to set them as integers.

Thanks to the both of ya!

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum