Forum Moderators: open
For x = 1 to ROOMS
ROOM_TYPE & x =Trim(Request("ROOM_TYPE" & x))
NUMBER_IN_ROOM & x =Trim(Request("NUMBER_IN_ROOM" & x))
OCCUPANT_NAMES & x =Trim(Request("OCCUPANT_NAMES" & x))
ARRIVAL_DATE & x =Trim(Request("ARRIVAL_DATE" & x))
DEPARTURE_DATE & x =Trim(Request("DEPARTURE_DATE" & x))
Next
The dynamically created variables will be assigned the values of a form I created that posts the information to this page.
Thanks for any suggestions.
'NB Assuming that ROOMS is an number
Dim sRoomData()Const ciRoomType = 0
Const ciRoomOccupants = 1
Const ciOccupantNames = 2
Const ciArrivalDate = 3
Const ciDepartureDate = 4ReDim sRoomData( 4, CLng( ROOMS ) - 1 )
For x = 1 To CLng( ROOMS )
sRoomData( ciRoomType, x-1 ) = Trim( Request("ROOM_TYPE" & x) )
sRoomData( ciRoomOccupants, x-1 ) = Trim( Request("NUMBER_IN_ROOM" & x) )
sRoomData( ciOccupantNames, x-1 ) = Trim( Request("OCCUPANT_NAMES" & x) )
sRoomData( ciArrivalDate, x-1 ) = Trim( Request("ARRIVAL_DATE" & x) )
sRoomData( ciDepartureDate, x-1 ) = Trim( Request("DEPARTURE_DATE" & x) )Next
Now in theory this would read in the form / querystring data and stash it away into a dynamically sized array. In other words the array is always the perfect size for the amount of data you are telling it you are going to give it...
Admittedly perhaps not as cute as the same approach using dynamic variables and/or separate arrays but it does work quite neatly and is nice and easy to maintain.
<notes>Added the constants to make it a little cleaner</notes>
-Tony