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

Populate an array manually and using getrows?

Status
Not open for further replies.

cr84net2

Programmer
Feb 8, 2005
93
US
I have a function that tests to see if a time is within a range of two other times. I am using military time only showing as an integer. (800, 830, 900, 930, 1000 etc)The statement that tests the range is below:

If tsToTest >= tsStart AND tsToTest < tsEnd Then


tsToTest is the time being tested. It is military time from 8:00 AM to 8:00 PM and is being fed by a manually populated array. The array is multidimensional, it has 3 columns and 25 rows. The two additional columns are being used in table cells to define the time. (8:00 - 8:30) The test statement is followed by a select statement to see if the "reservation" is approved.

tsStart AND tsEnd are only available in the database. I used getrows to retrieve them but when I loop through with the second array my table is duplicated when there is two records and I am assuming tripled if there were three.

Is it posible to manually populate some of the columns in an array and pull three other columns from a database? And to make this tougher, the three columns from the db could be empty or have any number of records.

I have tried using getrows around where I call the function but I get the same result.

Any help or ideas would be appreciated!
 
post your code and indictate where you see the problem, so we have a clearer picture
 
Heres the function:

Code:
Function timbetween()


CONST mtim = 0 
CONST btim = 1 
CONST etim = 2 

CONST MaxColumn = 2 
Dim MaxRow : MaxRow = 24 

Dim tarray() 
ReDim tarray( MaxColumn, MaxRow )

tarray(mtim,0) = 800 :tarray(btim,0) = "8:00":tarray(etim,0) = "8:30"
tarray(mtim,1) = 830 :tarray(btim,1) = "8:30":tarray(etim,1) = "9:00"
tarray(mtim,2) = 900 :tarray(btim,2) = "9:00":tarray(etim,2) = "9:30"
tarray(mtim,3) = 930 :tarray(btim,3) = "9:30":tarray(etim,3) = "10:00"
tarray(mtim,4) = 1000 :tarray(btim,4) = "10:00":tarray(etim,4) = "10:30"
tarray(mtim,5) = 1030 :tarray(btim,5) = "10:30":tarray(etim,5) = "11:00"
tarray(mtim,6) = 1100 :tarray(btim,6) = "11:00":tarray(etim,6) = "11:30"
tarray(mtim,7) = 1130 :tarray(btim,7) = "11:30":tarray(etim,7) = "12:00"
tarray(mtim,8) = 1200 :tarray(btim,8) = "12:00":tarray(etim,8) = "12:30"
tarray(mtim,9) = 1230 :tarray(btim,9) = "12:30":tarray(etim,9) = "1:00"
tarray(mtim,10) = 1300 :tarray(btim,10) = "1:00":tarray(etim,10) = "1:30"
tarray(mtim,11) = 1330 :tarray(btim,11) = "1:30":tarray(etim,11) = "2:00"
tarray(mtim,12) = 1400 :tarray(btim,12) = "2:00":tarray(etim,12) = "2:30"
tarray(mtim,13) = 1430 :tarray(btim,13) = "2:30":tarray(etim,13) = "3:00"
tarray(mtim,14) = 1500 :tarray(btim,14) = "3:00":tarray(etim,14) = "3:30"
tarray(mtim,15) = 1530 :tarray(btim,15) = "3:30":tarray(etim,15) = "4:00"
tarray(mtim,16) = 1600 :tarray(btim,16) = "4:00":tarray(etim,16) = "4:30"
tarray(mtim,17) = 1630 :tarray(btim,17) = "4:30":tarray(etim,17) = "5:00"
tarray(mtim,18) = 1700 :tarray(btim,18) = "5:00":tarray(etim,18) = "5:30"
tarray(mtim,19) = 1730 :tarray(btim,19) = "5:30":tarray(etim,19) = "6:00"
tarray(mtim,20) = 1800 :tarray(btim,20) = "6:00":tarray(etim,20) = "6:30"
tarray(mtim,21) = 1830 :tarray(btim,21) = "6:30":tarray(etim,21) = "7:00"
tarray(mtim,22) = 1900 :tarray(btim,22) = "7:00":tarray(etim,22) = "7:30"
tarray(mtim,23) = 1930 :tarray(btim,23) = "7:30":tarray(etim,23) = "8:00"
tarray(mtim,24) = 2000 :tarray(btim,24) = "8:00":tarray(etim,24) = "PM"



If Not rs.EOF Then

          Const rti  = 2
          Const rto = 3
          Const rap =10 
             dim alldata
             alldata=rs.getrows
       Else 
          Response.Write ""
          End If    
          For q = 0 to Ubound(alldata,2)
          tsStart = alldata(rti,q)
          tsEnd =  alldata(rto,q)
          resapp =  alldata(rap,q)

For i = 0 To Ubound(tarray,2) 
tsToTest = tarray(mtim,i)
timStar = tarray(btim,i)
timEnd = tarray(etim,i)





If tsToTest >= tsStart AND tsToTest < tsEnd Then

  
Select Case resapp
    Case True
        Response.write("<tr>" & vbNewline)
        Response.write("<td width=""100%"" bgcolor=""#000080"" style=""font-family: Arial"" height=""12"" align=""center"">" & vbNewline)
        Response.write("<p align=""center"">"& "<b><font face=""Arial"" size=""2"" color=""#FFFF00"">")& timStar & " - " &  timEnd &("</font></b></p>" & vbNewline)
        Response.write("</td>" & vbNewline)
        Response.write("</tr>" & vbNewline)
    Case False
        Response.write("<tr>" & vbNewline)
        Response.write("<td width=""100%"" bgcolor=""#FF8080"" style=""font-family: Arial"" height=""12"" align=""center"">" & vbNewline)
        Response.write("<p align=""center"">"& "<b><font face=""Arial"" size=""2"" color=""#00FFFF"">")& timStar & " - " &  timEnd &("</font></b></p>" & vbNewline)
        Response.write("</td>" & vbNewline)
        Response.write("</tr>" & vbNewline)
Case Else
       Response.Write ""
End Select
 
Else
        Response.write("<tr>" & vbNewline)
        Response.write("<td width=""100%"" style=""font-family: Arial"" height=""12"" align=""center"">" & vbNewline)
        Response.write("<p align=""center"">"& "<b><font face=""Arial"" size=""2"" color=""#000080"">")& timStar & " - " &  timEnd &("</font></b></p>" & vbNewline)
        Response.write("</td>" & vbNewline)
        Response.write("</tr>" & vbNewline)
End If
        
       
         Next 
        Next 
End Function

Before I added the getrows array this displayed nicely but only would show one time range during the 12 hour period.

When there are two time ranges to be checked this repeats all of the cells. (8:00 AM - 8:00 PM). It does display the time ranges appropriately (8:00 -10:00 and 4:00 - 8:00 in my test) But it shows the 8-10 with all 25 cells and immediately followed 25 cells with the 4-8 colorized.

Any ideas would be great.
 
ugh...

Code:
[red]
tarray(mtim,0) = 800 :tarray(btim,0) = "8:00":tarray(etim,0) = "8:30"
tarray(mtim,1) = 830 :tarray(btim,1) = "8:30":tarray(etim,1) = "9:00"
tarray(mtim,2) = 900 :tarray(btim,2) = "9:00":tarray(etim,2) = "9:30"
tarray(mtim,3) = 930 :tarray(btim,3) = "9:30":tarray(etim,3) = "10:00"
tarray(mtim,4) = 1000 :tarray(btim,4) = "10:00":tarray(etim,4) = "10:30"
tarray(mtim,5) = 1030 :tarray(btim,5) = "10:30":tarray(etim,5) = "11:00"
tarray(mtim,6) = 1100 :tarray(btim,6) = "11:00":tarray(etim,6) = "11:30"
tarray(mtim,7) = 1130 :tarray(btim,7) = "11:30":tarray(etim,7) = "12:00"
tarray(mtim,8) = 1200 :tarray(btim,8) = "12:00":tarray(etim,8) = "12:30"
tarray(mtim,9) = 1230 :tarray(btim,9) = "12:30":tarray(etim,9) = "1:00"
tarray(mtim,10) = 1300 :tarray(btim,10) = "1:00":tarray(etim,10) = "1:30"
tarray(mtim,11) = 1330 :tarray(btim,11) = "1:30":tarray(etim,11) = "2:00"
tarray(mtim,12) = 1400 :tarray(btim,12) = "2:00":tarray(etim,12) = "2:30"
tarray(mtim,13) = 1430 :tarray(btim,13) = "2:30":tarray(etim,13) = "3:00"
tarray(mtim,14) = 1500 :tarray(btim,14) = "3:00":tarray(etim,14) = "3:30"
tarray(mtim,15) = 1530 :tarray(btim,15) = "3:30":tarray(etim,15) = "4:00"
tarray(mtim,16) = 1600 :tarray(btim,16) = "4:00":tarray(etim,16) = "4:30"
tarray(mtim,17) = 1630 :tarray(btim,17) = "4:30":tarray(etim,17) = "5:00"
tarray(mtim,18) = 1700 :tarray(btim,18) = "5:00":tarray(etim,18) = "5:30"
tarray(mtim,19) = 1730 :tarray(btim,19) = "5:30":tarray(etim,19) = "6:00"
tarray(mtim,20) = 1800 :tarray(btim,20) = "6:00":tarray(etim,20) = "6:30"
tarray(mtim,21) = 1830 :tarray(btim,21) = "6:30":tarray(etim,21) = "7:00"
tarray(mtim,22) = 1900 :tarray(btim,22) = "7:00":tarray(etim,22) = "7:30"
tarray(mtim,23) = 1930 :tarray(btim,23) = "7:30":tarray(etim,23) = "8:00"
tarray(mtim,24) = 2000 :tarray(btim,24) = "8:00":tarray(etim,24) = "PM"
[/red]

looks like greek to me
 
I know, this was my first array.

Array( _
Array( 0800, "08:00", "08:30" ), _
Array( 0830, "08:30", "09:00" ), _
...
Array( 2000, "20:00", "20:30" ) _
)

Does this help? I just didn't want to rewrite the 75 values.
 
Ask for the code...Insult Me...and disappear? Nice Job! How do I take stars Away?
 
who insulted you, i just don't understand what you supplied - so i can't really help. I was waiting till someone else gave some input that i could understand.

Whats stars? No way to reach on a forum where your asking for help.
 
Sorry if I sounded pissy, I have been working on this for several days and banging my head against the wall. I evidently took your post the wrong way. Mine was meant as a tongue in cheek response to "ugh....looks like greek to me".

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top