Click to See Complete Forum and Search --> : FOR loop with array
piertiong
06-01-2003, 02:04 AM
hi there,
i have declared this array:
dim arrayTeam()
redim arrayTeam(3)
arrayTeam(0) = HumanLink
arrayTeam(1) = TrendyLink
arrayTeam(2) = Admin
and i'm using this loop to display a drop down list
<select name = "D1">
<option value='<%= team %>' selected><%= team
%></option><%
for i = 0 to arrayTeam.count()
if team != arrayTeam(i) then
%><option value = '<%= arrayTeam(i) %>'><%= arrayTeam(i) %></option><%
next
%></select>
there is a problem with the for loop around the "for i = 0 to arrayTeam.count()" part, what is it?
thanks alot for the help.
piertiong
06-01-2003, 05:14 AM
i have edited the code into the following:
<select name = "D1">
<option value="<%= team %>" selected>
<%= team %>
</option><%
for i = 0 to UBOUND(arrayTeam)
if NOT team.equals(arrayTeam(i)) then%>
<option value = '<%= arrayTeam(i) %>'>
<%= arrayTeam(i) %>
</option><%
end if
next
%>
</select>
Ribeyed
06-01-2003, 07:16 AM
Hi,
not to sure about this one but can you try changing this line:
if NOT team.equals(arrayTeam(i)) then
to
if Team <> arrayTeam(i) then
Hope this helps
piertiong
06-01-2003, 07:21 AM
Originally posted by [SWR]Ribeyed
Hi,
not to sure about this one but can you try changing this line:
if NOT team.equals(arrayTeam(i)) then
to
if Team <> arrayTeam(i) then
Hope this helps
thanks for your help! will try it.
piertiong
06-01-2003, 07:23 AM
it worked. i could never thank you enough, sir. thanks!
Ribeyed
06-01-2003, 07:35 AM
i am glad, np:D
piertiong
06-01-2003, 07:43 AM
Originally posted by [SWR]Ribeyed
i am glad, np:D
thanks once again. :D :)
piertiong
06-01-2003, 10:35 AM
Originally posted by Dave Clark
This part should not be working for an array:
for i = 0 to arrayTeam.count()
That should be more like this:
for i = 0 to UBound(arrayTeam)
Dave
yup i did just that. i searched through the web, and found that we are able to calculate the difference in date. but could we find out the difference in time formats? like 13:30 - 12:30 gives 1 hour. :confused: thanks :)
piertiong
06-01-2003, 11:34 PM
Originally posted by Dave Clark
You're probably referring to the DateDiff() function. That function can also tell you the difference between two times. In other words, Date objects also contain a time portion.
Dave
yes i have figured that out, thanks a million.
piertiong
06-02-2003, 01:37 PM
can i do this?
SQL1 = "select timeIn from attendIn where stud_admin= '" & result & "'"
Set objRS1 = Server.CreateObject ("ADODB.Recordset")
Set objRS1 = objConn.execute(SQL1)
time1 = objRS1("timeIn") 'timeIn is of type LONG TIME
if DateDiff("n",onTime,time1) > 0 and tempTL<60 then
'etc etc
piertiong
06-02-2003, 11:24 PM
Originally posted by Dave Clark
You should test it to be sure -- but I'd say, probably not. The value coming from your database will just be a number. You would need to convert the number to the time portion of a Date object.
Dave
it could not work.
piertiong
06-03-2003, 09:21 AM
i'm having this problem now:
Set objrs2 = objConn.execute("SELECT attendNum FROM attendIn where dateIn = '"& dateIn &"' and timeIn = '"& timeIn &"' and stud_admin = '"& result &"'")
Microsoft OLE DB Provider for ODBC Drivers error '80040e07'
[Microsoft][ODBC Microsoft Access Driver] Data type mismatch in criteria expression.
/Attendance/attendance_in.asp, line 28
dateIn and timeIn is of type date/time in access database
and stud_admin is of type string.
piertiong
06-04-2003, 03:20 AM
ok i've done that, sorry. hopefully this will be the last question :o
can i do this?
set objrs1 = objConn.execute("select * from flexiLeave WHERE dateLeave >= #"& startWeek &"# AND dateLeave <= #"& endWeek &"#")
i have converted dateLeave, startWeek and endWeek to date/time using TimeValue().
need to check if dateLeave is between startWeek and endWeek
edited/added
how about this?
set objrs1 = objConn.execute("select * from flexiLeave WHERE DateDiff("n",startWeek,dateLeave) >= 0 AND DateDiff("n",dateLeave,endWeek) >= 0")
oops this definately would not work :p
anyway, is there a way to check if dateLeave is between startWeek and endWeek?
as i need to select * from flexileave where dateleave is between startWeek and endWeek