Results 1 to 14 of 14

Thread: Fixing a value to an element of array.

Threaded View

  1. #1

    Thread Starter
    Member
    Join Date
    Jan 2007
    Posts
    32

    Fixing a value to an element of array.

    I hope I got the terminology right.

    I'm creating a simple hotel reservation system.

    The inputbox will validate the users (called a, b, and c) and will loop if the name is wrong. I have no problem at this part.

    Next, if the name matches the array of users I have just stored, they will be allowed to book a room. (room 1, 2 , or 3)

    Here is my problem, how do I attach the room number with particular users so that when the next user use the program (without exiting the program so that memory is not dumped), they will not be allowed to book rooms that have been booked before.


    Here is my simple code.


    VB Code:
    1. guest(0) = "a"
    2. guest(1) = "b"
    3. guest(2) = "c"
    4.  
    5.  
    6. Do
    7.         strinput = InputBox("Who are you?")
    8.         'Check if the name is in the array
    9.     For i = 0 To 2
    10.         If guest(i) = strinput Then
    11.                 blnvalid = True
    12.             ElseIf strinput = "x" Then
    13.             End
    14.             End If
    15.             Next i
    16.     'Loop while a valid name has not been entered
    17.     Loop While Not blnvalid
    18.  
    19. 'PROBLEM STARTS HERE
    20.  
    21. room = InputBox("Choose a room")
    22.  
    23. Do While room < 1 Or room > 3
    24. room = InputBox("Out of range. reenter room 1-3 please")  
    25. Loop                            
    26.  
    27. 'How do I attach particular element of array to
    28. 'the room number so that no element of array (a, b, c)
    29. 'can have the same room number
    Last edited by vert; Jan 30th, 2007 at 12:25 PM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width