Hi all,

I just need to check and see if a number, stored in a string, is greater
than a particular value. I realize that the VAL function isn't supported
under embedded VB, but CINT isn't working either, so I must be doing
something wrong. Look at this code:

If (CInt(lblLabel.Caption) < 8000) Then

'Display an error message
MsgBox "The number you scanned is invalid.", vbExclamation, APP_TITLE

'Exit the procedure
Exit Sub

End If

I get an "Overflow: CInt" error.

I've tried first declaring seperate string and integer variables to hold
the values in and then initializing them:

Dim TempCode As Double
Dim TempString As String

TempString = "1"
TempCode = 1
TempString = lblLabel.Caption
TempCode = TempString

If (CInt(TempCode) < 8000) Then

'Display an error message
MsgBox "The number you scanned is invalid.", vbExclamation, APP_TITLE

'Exit the procedure
Exit Sub

End If

But I still get the same error.

So what am I doing wrong? How can I check that the value stored in a label,
or at least in a string variable, is greater than a given number (> 8000 in
this particular case). TIA!

- Dave

Re: eVB - Convert string to number for comparison? by Dave

Dave
Mon Jan 19 15:05:51 CST 2004

"Dave" <im@not.telling> wrote in message news:x-mdnQ8R0sTPrJHdRVn-iQ@giganews.com...
> Hi all,
>
> I just need to check and see if a number, stored in a string, is greater
> than a particular value. I realize that the VAL function isn't supported
> under embedded VB, but CINT isn't working either, so I must be doing
> something wrong. Look at this code:

Nevermind all. Basically I just got rid of the CInt call and jammed the
string into an integer variable and it worked fine.

- Dave