Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

String variable verses numeric variable... 1

Status
Not open for further replies.

martindavey

Programmer
Jan 2, 2000
122
GB
Take the following example:

<%
STATUS = Request(&quot;Status&quot;)
If STATUS = &quot;Show&quot; Then
AGE = Request(&quot;Age&quot;)
For i = 18 to 21
Response.Write(i)
If i = AGE Then
Response.Write(&quot; = Your Age&quot;)
End If
Response.Write(&quot;<br>&quot; &vbcrlf)
Next
Else
%>
<form name=&quot;myForm&quot; action=&quot;thisPage.asp&quot;>
<input type=&quot;hidden&quot; name=&quot;Status&quot; value=&quot;Show&quot;>
<select name=&quot;Age&quot;>
<option id=&quot;18&quot;>18</option>
<option id=&quot;19&quot;>19</option>
<option id=&quot;20&quot;>20</option>
<option id=&quot;21&quot;>21</option>
</select>
<input type=&quot;submit&quot; value=&quot;Show&quot;>
</form>
<% End If %>

When I run this, AGE is correctly retreived from the QueryString, but the 'IF' condition doesn't evaluate to true even though they appear to match.

Is this some sort of string vs. number data type problem - if so, how do I convert one to the other.

Cheers, Martin.
 
All data u get in the asp from Request object is an string data if u need to convert it in an number
use AGE = Int(Request(&quot;Age&quot;))
all the comparisons are as the string ones if u dont convert it to an number ________
George, M
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top