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
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
Do you have a function which will return a numeric equivalent of a string?
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
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...