• 0

VB Help :S


Question

ok peepz

try to figure this out lol

i have a label with "3hrs 5minz 3secs" in it ...can i make VB ignore the letters in that so i can use it in a Sum or in a Greater Than (>) or Less Than situation (<)...because with the letters in it i cant do something like...

If Alabel.Caption > SomeotherLabel.Caption Then

Label.Caption = AnotherLabel.Caption

End If

coz if i have letters in em VB wont let me do that but if i have just numbers in it i can use the

If Val(Label.Caption) > Val(Label1.Caption) Then

Yadayadayada

End If

please help :s and no..i cant just get rid of the letters :p lol please help

PS.. if u still dont get what this is about...more simpler...how can i ignore the letters in a Label caption but still have them showing

thnx

digi

Link to comment
Share on other sites

7 answers to this question

Recommended Posts

  • 0

....

Val command thing will only make a caption that is numbers already into propper numbers..eg. "123" will go to 123 for VB to do its sums ect...

what i reallly mean is like uhh..its quite hard to explain especailly without explaining the whole situation

its like

i have a caption "1hr, 3secs" and i need it to ignore the letters so it will be "13" so i can then go, if "1hr, 3secs" = Label.Caption which if letters are ignored is 13!,

If Label.Caption (13) = Somethingelse.Caption Then

Do Stuff

End If

Link to comment
Share on other sites

  • 0

If you have to try the following:

dim timestring(3) as integer

dim mycount as integer

mycount = 1

for i = 1 to len(Alabel.Caption)

if val(mid(Alabel.Caption),i,1) <> "" then

timestring(mycount) = then timestring(mycount) & val(mid(Alabel.Caption),i,1)

else

mycount = mycount +1

end if

next i

Crude but will give you access to the numbers

Link to comment
Share on other sites

  • 0

It's taken me a while but I think I've got it... :D

lblOriginal is the label with the letters and everything, and NewString and lblNew contain only the integers from lblOriginal.

&lt;pre&gt;Sub CharCount()

    Dim i As Integer

    Dim TempString As String

    Dim TempChar As String

    Dim NewString As String

    For i = 1 To Len(lblOriginal.Caption)

    TempChar = Mid(lblOriginal.Caption, i, 1)

    If Asc(TempChar) &lt; 58 And Asc(TempChar) &gt; 47 Then

        NewString = TempString &amp; TempChar

        TempString = NewString

    End If

    Next i

    lblNew.Caption = NewString

End Sub&lt;/pre&gt;

Link to comment
Share on other sites

This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.