By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,949 Members | 1,632 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,949 IT Pros & Developers. It's quick & easy.

I thought <> works on strings? no?

P: n/a
I've got some code like this:
gametype_id = Request.Form("gametype_id")
response.write "<br>gametype_id from form>" & gametype_id & "<"
response.write "<br>gametype_id from database>" &
rs_state("gametype_id") & "<"

if gametype_id = "" then
gametype_id = rs_state("gametype_id") 'could be NULL and make
gametype_id NULL
else
'the gametype from the form is not empty or NULL, so consider
updating the database record

'strComp returns -1 if the first value is smaller, a 0 if they're
equal, a 1 if the second value is smaller, or Null if either input is
Null.
'if strComp(gametype_id, rs_state("gametype_id"), vbTextCompare) <>
0 then
'nothing

if gametype_id <rs_state("gametype_id") then
response.write "<br>updating gametype_id"
sql = "update maxminisuser set gametype_id = " & gametype_id & "
where userid =" & userid
conn.execute sql, , 129
end if
end if
ok now when I run the page I get this:

gametype_id from form>1<
gametype_id from database>1<
updating gametype_id <------WHY is this happening??

if I have two strings both equaling "1" as printed out above then why
does the line:

if gametype_id <rs_state("gametype_id") then...

evaluate as true?????

<is not equal to, as far as I know this works on strings??

when I use if strComp then it performs as expected, however <is more
logical and readable and I want to understand why it is happening.

On the same page I have this statement:
if "1" = "1" then response.write "<br>1=1"
and it writes 1=1

when I do this
if "1" <"1" then
response.write "1<>1"
end if

then it doesnt write anything
?????

so whats the difference between that line and
if gametype_id <rs_state("gametype_id")
when both expressions printed out as "1" just before its evaluated??

soooo confused. What am I missing here???

-Mike

Jul 29 '06 #1
Share this Question
Share on Google+
1 Reply


P: n/a

"mike" <mi*************@yahoo.comwrote in message
news:11*********************@m73g2000cwd.googlegro ups.com...
I've got some code like this:
gametype_id = Request.Form("gametype_id")
response.write "<br>gametype_id from form>" & gametype_id & "<"
response.write "<br>gametype_id from database>" &
rs_state("gametype_id") & "<"
You should not write < or to a HTML form because it will be interpreted by
a browser to be a tag.
so write &lt; resp &gt; for < and >
if gametype_id = "" then
gametype_id = rs_state("gametype_id") 'could be NULL and make
gametype_id NULL
else
'the gametype from the form is not empty or NULL, so consider
updating the database record

'strComp returns -1 if the first value is smaller, a 0 if they're
equal, a 1 if the second value is smaller, or Null if either input is
Null.
'if strComp(gametype_id, rs_state("gametype_id"), vbTextCompare) <>
0 then
'nothing

if gametype_id <rs_state("gametype_id") then
response.write "<br>updating gametype_id"
sql = "update maxminisuser set gametype_id = " & gametype_id & "
where userid =" & userid
conn.execute sql, , 129
end if
end if
ok now when I run the page I get this:

gametype_id from form>1<
gametype_id from database>1<
updating gametype_id <------WHY is this happening??

if I have two strings both equaling "1" as printed out above then why
does the line:

if gametype_id <rs_state("gametype_id") then...

evaluate as true?????

<is not equal to, as far as I know this works on strings??

when I use if strComp then it performs as expected, however <is more
logical and readable and I want to understand why it is happening.

On the same page I have this statement:
if "1" = "1" then response.write "<br>1=1"
and it writes 1=1

when I do this
if "1" <"1" then
response.write "1<>1"
end if

then it doesnt write anything
?????

so whats the difference between that line and
if gametype_id <rs_state("gametype_id")
when both expressions printed out as "1" just before its evaluated??
the datatypes differ. So use
if clng(gametype_id ) <rs_state("gametype_id") etc

or use CStr to make them string for comparision (not sure what datatype you
compare).

Jul 29 '06 #2

This discussion thread is closed

Replies have been disabled for this discussion.