tags:

views:

88

answers:

4

Hi All, I want to compare two values which is coming as string input. please help me how to compare this values

strA = "25.03"
strB = "-25.02"

Raja

A: 

Do you have a function which will return a numeric equivalent of a string?

pavium
A: 

You can convert them to values with the val function, and then you can make any comparation

valA = Val(strA)
valB = Val(strB)

If valA > valB Then
  ' Do whatever you need
End If
Jhonny D. Cano -Leftware-
VBScript doesn't have the `Val` function.
Helen
+5  A: 
Cdbl(strA) < Cdbl(strB)

will cast them to double

Svetlozar Angelov
+1  A: 

It might help to know what kind of validation you want to do.

String?

strA = "25.03"
strB = "-25.02"
If strA > strB Then
   'do whatever'
End If

Numeric reguardless of sign?

strA = "25.03"
strB = "-25.02"
If Abs(strA) > Abs(strB) Then
   'do whatever'
End If

Numeric including the decimal?

strA = "25.03"
strB = "-25.02"
If cDbl(strA) > cDbl(strB) Then
   'do whatever'
End If

Numeric excluding the decimal?

strA = "25.03"
strB = "-25.02"
If cInt(strA) > cInt(strB) Then
   'do whatever'
End If

More information and context would go a long way in getting you the answer you need...

AnonJr