1. Stores 5 usernames in an array on strings
2. Asks user for their ID then validates it
3. Asks them for their desired seat number
4. Displays booking details.
Problem is, one user can keep going around in a loop and book every available seat. I want to display something that says "You have already booked a seat, would you like to change your seat?
Not sure how I would do this, I tried doing it with 2-D arrays but I only done a little on those and I'm not sure how to go about doing so.
Here is my code (I tidied it up as much as I could :S)
Private Sub Command1_Click() 'Declare Variables Dim ids(5) Dim responce As Integer Dim bookings(5) Dim inputval(5) 'Call Sub Routines Call create_arrays(ids(), flightnr, bookings()) Do Call check_id(ids(), pasid, inputval()) Call book_seat(bookings(), pasid, seatnr, ids()) Call display_results(flightnr, pasid, seatnr) 'Ask user if they want to exit responce = MsgBox("Do you need to enter another value?", vbYesNo, "Exit?") Loop Until responce = vbNo End Sub Private Sub create_arrays(ByRef ids(), flightnr, bookings()) 'Create arrays/store flight details ids(0) = "WallaceW48P01" ids(1) = "LauderH468P02" ids(2) = "CarnegieA468P3" ids(3) = "ScottW468P04" ids(4) = "DeBruisR468P05" flightnr = "HA468" bookings(1) = "" bookings(2) = "" bookings(3) = "" bookings(4) = "" bookings(5) = "" End Sub Private Sub check_id(ByRef ids(), pasid, inputval()) 'Declare Variables Dim found As Boolean Dim counter As Integer Dim counter2 As Integer 'Get user Input pasid = InputBox("Enter your user ID") 'Input Validations Do For counter = 0 To 4 If ids(counter) = pasid Then found = True MsgBox ("The ID you was accepted") If Not found Then MsgBox ("The ID you entered was invalid") Else End If Next Loop Until found = True End Sub Private Sub book_seat(ByRef bookings(), ByVal pasid, ByRef seatnr, ids()) 'Declare variables Dim found As Boolean 'Get input seatnr = InputBox("Enter your desired seat number Between 1 and 5") 'Input Validation Do Do If seatnr < 1 Or seatnr > 5 Then seatnr = InputBox("That was an invalid number, Please enter your desired seat number Between 1 and 5") End If Loop Until seatnr >= 1 And seatnr <= 5 If bookings(seatnr) = "" Then found = True bookings(seatnr) = "taken" Else MsgBox ("seat number " & seatnr & " was not available") End If Loop Until found = True If Not found Then MsgBox ("Your seat has been booked") End Sub Private Sub display_results(ByVal flightnr, pasid, seatnr) 'Declare Variables Dim pasid2 As String 'string concatenation pasid2 = Mid$(pasid, 1, Len(pasid) - 6) 'Display Results txtbox.AddItem " Booking Confirmation" txtbox.AddItem "Flight Number :" & flightnr txtbox.AddItem "ID :" & pasid txtbox.AddItem "Name :" & pasid2 txtbox.AddItem "Seat Number :" & seatnr End Sub