Hello everyone, here i am again, asking for help .... please bear with me, I am a newbie of VB .... ahmmmm I just wanna ask if what codes is appropriate in holding the value that the user choose or select after clicking the ENTER Button? the scenario is this: I have 5 buttons, namely: A1, A2, A3, A4, A5 and when a user Select any of the buttons, a MsgBox("The Seat number you select is" _____, "Do You want to Continue", vbYesNo + vbQuestion) will appear after Clicking the Enter Button .... the codes i have done so far is:
Private Sub ENTER_Click(sender As Object, e As EventArgs) Handles ENTER.Click
con = New System.Data.OleDb.OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\Users\laptop\Documents\Trial\Sample.accdb")
con.Open()
Dim Buttons As New List(Of Button) From {A1, A2, A3, A4, A5}
For Each btn As Button In Buttons
If btn.BackColor = Color.Red Then
cmd.CommandType = CommandType.Text
cmd.CommandText = "Update RegularPassenger Set Filled=@StFld Where SeatNo=@StNo"
cmd.Parameters.Add("@StFld", OleDb.OleDbType.VarChar, 10).Value = "RESERVED"
cmd.Parameters("@StFld").Direction = ParameterDirection.Input
cmd.Parameters.Add("@StNo", OleDb.OleDbType.VarChar, 10).Value = btn.Name
cmd.Connection = con
cmd.ExecuteNonQuery()
cmd.Parameters.Clear()
cmd.Dispose()
Exit For
End If
Next
con.Close()
con.Dispose()
If MsgBox("You Select the Seat Number " "Do You want to continue?", vbYesNo + vbQuestion, _
"Philippine Sweet Airline") = vbYes Then
Me.Close()
End If
End Sub
Private Sub A3_Click(sender As Object, e As EventArgs) Handles A1.Click, A2.Click, A3.Click, A4.Click, A5.Click
Dim BSender As Button = CType(sender, Control)
If BSender.BackColor = Color.Red Then
BSender.BackColor = Color.WhiteSmoke
Return
End If
Dim Buttons As New List(Of Button) From {A1, A2, A3, A4, A5} 'Buttons you want to check
Dim BError As Boolean = False
For i = 0 To Buttons.Count - 1
If Buttons(i).BackColor = Color.Red Then
BError = True
End If
Next
If BError = False Then
sender.BackColor = Color.Red
Else
MsgBox("You can only select one seat for every Process", vbInformation, _
"Philippine Sweet Airline")
End If
End Sub
What code is appropriate for the Condition? I will really appreciate any HELP ..... Thank You so MUCH!!!:'(