Filtering with figures
Posted on 2004-10-11
Here's my problem:
My App Users have to enter a minimum age and a maximum age in 2 TextBoxes (respectively : txtAge1 and txtAge2)
Dim Age1 As String = txtAge1.Text
Dim Age2 As String = txtAge2.Text
I have a data field in my DataTable that is named "Age". Therefore "Age" >= Age1 And "Age" <= Age2 which reads (My code) :
If txtAge1.Text.Trim <> "" And txtAge2.Text.Trim <> "" Then
strFilter += "Age >= '" & txtAge1.Text & "' AND "
strFilter += "Age <= '" & txtAge2.Text & "' '"
The filter works fine except for certain values e.g. min 5 and max 25. It seems that this is due to the fact that these are STRING comparisons, which means 5 in higher than 25 because 5 > 2.
Does anyboduy know how to resolve this issue?