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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Compare Integers

Status
Not open for further replies.

dhoward007

Programmer
Feb 6, 2002
45
US
I am building an asp application and cannot figure out how to compare two integers.. Is this possible using vbscript?

Below is a brief example of what I am trying to do.. Any suggestions??

dim strIntOne
dim strIntTwo


strIntOne = CInt(rsValues("value"))

strIntTwo = CInt(rsValues("valueTwo"))


IF strIntOne = strIntTwo THEN

Action

ELSE

Action

END IF



 
nothing wrong with your example. why/how is this not working

____________________________________________________
[sub]The most important part of your thread is the subject line.
Make it clear and about the topic so we can find it later for reference. Please!! faq333-3811[/sub]
onpnt2.gif
 
Well.. Here is a section of the code that I am using..

First, I create one recordset for the comparison.

'Get the duration Hours from the srcboduration table for populating the durationHour combo box.
drQryH = "select cbovalue, cboname from srcboduration where cboType = 'H'"
SET rsDurationHour = CreateObject("adodb.recordset")
rsDurationHour.Open drQryH, SDBConnect, adOpenForwardOnly


Now I will get the second recordset.. This one will only return one record.

'Now get the hours and minutes for the record that needs updating.
drHourMinutes = "select cast(sum(durprojectDuration) / 60 as varchar(10)) as Hours, cast(sum(durprojectDuration) % 60 as varchar(10)) as Minutes from srduration where durID ='" & strDurID & "'"
SET rsHours = CreateObject("adodb.recordset")
rsHours.Open drHourMinutes, SDBConnect, adOpenForwardOnly
strHours = CInt(rsHours("hours"))

Now I will compare the values from the first recordset with the second recordset and if they match, I will change the value of the combo box to selected.

<select name=&quot;cboDurationHourAdd&quot;>
<option value=&quot;0&quot;>Hour</option>
<% Do Until rsDurationHour.EOF %>
<% IF strHours = CInt(rsDurationHour(&quot;cboValue&quot;)) THEN%>
<option value=&quot;<%=rsDurationHour(&quot;cboValue&quot;)%>&quot; selected><%=rsDurationHour(&quot;cboName&quot;)%></option>
<%ELSE%>
<option value=&quot;<%=rsDurationHour(&quot;cboValue&quot;)%>&quot;><%=rsDurationHour(&quot;cboName&quot;)%></option>
<%END IF%>
<%rsDurationHour.MoveNext %>
<% LOOP %>
</select>
<% rsDurationHour.Close %>

For some reason, the combo is not working properly.. No values are selected when I run this.. I know there are values that match but I'm not sure why it's not working.
 
have you tried echo'in the values you are trying to compare?
your code looks fine, ie the CInt() etc.
try echo'in these CInt()'s just to check you really are getting back what you think you should be
 
Thanks Guys. I wasn't multiplying the minutes by 60 therefore I wasn't getting the results that I expected.. It works now..

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top