I posted my problem in ref to my Airline Reservation Program. I am using VB 2005 for this program
I have to right a program that req a users name for a text box then assigns the user a seat (row(x), seat(x). The seat assignment is based on a two dimensional array seatingchart(9, 3). When the user enters name in the text box a click event must be activated in order to store the passenger in a variable string passenger. I also have a control array btnseatresv(9,3 ) that display a 10 X 4 tabular table of button which signifies the seat location, if a seat is red then the seat is already taken if the seat is green then the seat is open. each button has a click event on it. I am having some problems with the logic behind the code.
1. When the passenger name is typed in the text box and the addpassenger button is clicked it assigns the variable to the passenger name code below:
passenger = txtPassName.Tex t
then an input box is displayed which then ask the user to enter the row pass wants to seat in. (See Below)
rowpos = CInt(InputBox(" Please enter row passenger wants to seat in:"))
next another input box is displayed which then ask the user to enter the seat pass wants to seat in. (See Below)
colpos = CInt(InputBox(" Please enter seat passenger wants to seat in:"))the if statement is neccessary to determine if seat has already been taken
(this line of code does not work: need help
If btnSeatResv(row pos - 1, colpos - 1).Enabled <> True Then
MsgBox("Seat already taken. Please choose another seat") Else
basically it alway skip the first part of if statement and goes to the else portion rather the seat has already been assigned or not.
the next line of code assigns the pass name and desired seat location.
SeatingChart(ro wpos - 1, colpos - 1) = passenger & " Row " & rowpos & " " & "Seat " & colpos
it then assigns the location to the btnarray and change color from green to red and enables it. (see below)
btnSeatResv(row pos - 1, colpos - 1).BackColor = Color.Red
btnSeatResv(row pos - 1, colpos - 1).Enabled = False
This works for the first passenger assignment but when I try to add another passenger it does not change the color of button and disable it, but it does assign to seating chart array
Can anyone give my some suggestions to how to fix my code I need the project done by 11:59 pm tonight. Code is given agian but not broken up below
I thank you all and appreiciate your suggestions
(ARRAYS ARE DECLARED OUT SIDE OF THE btnAddPass procedure)
Private Sub btnAddPass_Clic k(ByVal sender As System.Object, ByVal e As System.EventArg s) Handles btnAddPass.Clic k
Dim row, row2 As Integer
Dim col, col2 As Integer
Dim x As Integer = 221
Dim y As Integer = 150
Dim a As Integer = 128
Dim b As Integer = 153
Dim c As Integer = 150
Dim d As Integer = 130
Dim rowpos As Integer
Dim colpos As Integer
Dim passenger As String
AddButton(row, col, x, y)
AddSeatLabel(co l2, c, d)
AddRowNum(row2, a, b)
passenger = txtPassName.Tex t
rowpos = CInt(InputBox(" Please enter row passenger wants to seat in:"))
colpos = CInt(InputBox(" Please enter seat passenger wants to seat in:"))
If btnSeatResv(row pos - 1, colpos - 1).Enabled <> True Then
MsgBox("Seat already taken. Please choose another seat")
Else
SeatingChart(ro wpos - 1, colpos - 1) = passenger & " Row " & rowpos & " " & "Seat " & colpos
btnSeatResv(row pos - 1, colpos - 1).Text = " "
btnSeatResv(row pos - 1, colpos - 1).BackColor = Color.Red
btnSeatResv(row pos - 1, colpos - 1).Enabled = False
End If
txtPassName.Cle ar()
txtPassName.Foc us()
End Sub
I have to right a program that req a users name for a text box then assigns the user a seat (row(x), seat(x). The seat assignment is based on a two dimensional array seatingchart(9, 3). When the user enters name in the text box a click event must be activated in order to store the passenger in a variable string passenger. I also have a control array btnseatresv(9,3 ) that display a 10 X 4 tabular table of button which signifies the seat location, if a seat is red then the seat is already taken if the seat is green then the seat is open. each button has a click event on it. I am having some problems with the logic behind the code.
1. When the passenger name is typed in the text box and the addpassenger button is clicked it assigns the variable to the passenger name code below:
passenger = txtPassName.Tex t
then an input box is displayed which then ask the user to enter the row pass wants to seat in. (See Below)
rowpos = CInt(InputBox(" Please enter row passenger wants to seat in:"))
next another input box is displayed which then ask the user to enter the seat pass wants to seat in. (See Below)
colpos = CInt(InputBox(" Please enter seat passenger wants to seat in:"))the if statement is neccessary to determine if seat has already been taken
(this line of code does not work: need help
If btnSeatResv(row pos - 1, colpos - 1).Enabled <> True Then
MsgBox("Seat already taken. Please choose another seat") Else
basically it alway skip the first part of if statement and goes to the else portion rather the seat has already been assigned or not.
the next line of code assigns the pass name and desired seat location.
SeatingChart(ro wpos - 1, colpos - 1) = passenger & " Row " & rowpos & " " & "Seat " & colpos
it then assigns the location to the btnarray and change color from green to red and enables it. (see below)
btnSeatResv(row pos - 1, colpos - 1).BackColor = Color.Red
btnSeatResv(row pos - 1, colpos - 1).Enabled = False
This works for the first passenger assignment but when I try to add another passenger it does not change the color of button and disable it, but it does assign to seating chart array
Can anyone give my some suggestions to how to fix my code I need the project done by 11:59 pm tonight. Code is given agian but not broken up below
I thank you all and appreiciate your suggestions
(ARRAYS ARE DECLARED OUT SIDE OF THE btnAddPass procedure)
Private Sub btnAddPass_Clic k(ByVal sender As System.Object, ByVal e As System.EventArg s) Handles btnAddPass.Clic k
Dim row, row2 As Integer
Dim col, col2 As Integer
Dim x As Integer = 221
Dim y As Integer = 150
Dim a As Integer = 128
Dim b As Integer = 153
Dim c As Integer = 150
Dim d As Integer = 130
Dim rowpos As Integer
Dim colpos As Integer
Dim passenger As String
AddButton(row, col, x, y)
AddSeatLabel(co l2, c, d)
AddRowNum(row2, a, b)
passenger = txtPassName.Tex t
rowpos = CInt(InputBox(" Please enter row passenger wants to seat in:"))
colpos = CInt(InputBox(" Please enter seat passenger wants to seat in:"))
If btnSeatResv(row pos - 1, colpos - 1).Enabled <> True Then
MsgBox("Seat already taken. Please choose another seat")
Else
SeatingChart(ro wpos - 1, colpos - 1) = passenger & " Row " & rowpos & " " & "Seat " & colpos
btnSeatResv(row pos - 1, colpos - 1).Text = " "
btnSeatResv(row pos - 1, colpos - 1).BackColor = Color.Red
btnSeatResv(row pos - 1, colpos - 1).Enabled = False
End If
txtPassName.Cle ar()
txtPassName.Foc us()
End Sub
Comment