2014-09-26 63 views
0

「從字符串」行E1:2個席位2「到類型'布爾'的轉換無效。」「從字符串」Row E1:2 seats2「轉換爲類型'Boolean'無效。」

請幫忙 我正在製作電影預約系統。我需要能夠預訂座位,並檢查了座位 1-6個席位和AE排 表單定義的可用性:

Public Class Form1 
    Dim seats(5) As String //'this declares the array seats as string' 
    Dim firstseat As Integer //'this declares first seat as integer' 
    Dim rowid As Integer //'this declares row id as integer' 
    Dim numseats As Integer //'this declares numseats as integer' 
    Dim bookseats As Integer //'this declares book seats as integer' 
    Dim currentseat As Char //'this declares current seat as char' 

其他子定義:

Private Sub Form1_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load 
     For x = 0 To 4 
      seats(x) = "0000000000" 'seats equals 0000000000' 
     Next 'moves onto the next stage' 
     Button2.Enabled = False ' this means you cannot click button 2' 
    End Sub 
Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click 
    If ComboBox1.Text = "" Then 'if combobox 1 equals empty then a message box appears' 
     MessageBox.Show("please select a row") 'message box appears showing please select a row' 
     Return 
    End If 'this ends the if function' 
    If ComboBox2.Text = "" Then 'if combo box 2 equals empty then a message box appears' 
     MessageBox.Show("please select seats") ' message box appears showing please select seats' 
     Return 
    End If ' this ends the if function' 
    If ComboBox1.Text = "A" Then ' if combo box 1 equals A then row id equals 4' 
     rowid = 4 

    ElseIf ComboBox1.Text = "B" Then ' if combo box 1 equals B then row id equals 3' 
     rowid = 3 

    ElseIf ComboBox1.Text = "C" Then ' if combo box 1 equals C then row id equals 2' 
     rowid = 2 
    ElseIf ComboBox1.Text = "D" Then ' if combo box 1 equals D then row id equals 1' 
     rowid = 1 
    ElseIf ComboBox1.Text = "E" Then ' if combo box 1 equals E then row id equals 0' 
     rowid = 0 
    End If 'ends the if statement' 
    numseats = Val(ComboBox2.Text) 'numseats equals val combobox 2' 
    bookseats = 0 'book seats equals 0' 
    For i = 1 To 10 
     currentseat = Mid(seats(rowid), i, 1) 'current seat equals mid seats rowid i 1' 
     If currentseat = "1" Then 'if current equals 1 then' 
      bookseats = bookseats + 1 'bookseats equals bookseats plus 1' 
     End If 'this ends the if function' 
    Next 'moves onto the next stage'     
    If 10 - bookseats < numseats Then 'if 10 - bookseats is less than numseats then' 
     MessageBox.Show("no seats available") 'message appears showing no seats available' 
    Else 'or' 
     For i = 1 To 10 

      firstseat = InStr(seats(rowid), "0") 
     Next 'move onto the next stage' 


     If firstseat = "1" Then 
      MessageBox.Show("1 seat selected") 'if first seat is 1 then messagebox appears saying 1 seat selected' 
     ElseIf firstseat = "2" Then 
      MessageBox.Show("2 seats selected") 'if first seat is 2 then messagebox appears saying 2 seats selected' 
     ElseIf firstseat = "3" Then 
      MessageBox.Show("3 seats selected") 'if first seat is 3 then messagebox appears saying 3 seats selected' 
     ElseIf firstseat = "4" Then 
      MessageBox.Show("4 seats selected") 'if first seat is 4 then messagebox appears saying 4 seat selected' 
     ElseIf firstseat = "5" Then 
      MessageBox.Show("5 seats selected") 'if first seat is 5 then messagebox appears saying 5 seats selected' 
     ElseIf firstseat = "6" Then 
      MessageBox.Show("6 seats selected") 'if first seat is 6 then messagebox appears saying 6 seats selected' 
     End If 'ends the if statement' 
    End If 'ends the if statement' 
     If 10 >= numseats Then 'if 10 - more than or equal to numseats then' 
      MessageBox.Show("seats available") 'messagebox appears showing seats available' 
     End If 'ends the if statement' 

    If ComboBox1.Text & firstseat & ":" & ComboBox2.Text & (firstseat + numseats - 1) Then 
     Button2.Enabled = True 
    End If 'ends the if statement' 
    If ComboBox2.Text = "1 seat" Then 'if combobox2 equals 1 seat then numseats equals 5' 
     numseats = 5 
    ElseIf ComboBox2.Text = "2 seats" Then 'if combobox2 equals 2 seats then numseats equals 4' 
     numseats = 4 
    ElseIf ComboBox2.Text = "3 seats" Then 'if ComboBox2 equals 3 seats then numseats equals 3' 
     numseats = 3 
    ElseIf ComboBox2.Text = "4 seats" Then 'if combobox2 equals 4 seats then numseats equals 2' 
     numseats = 2 
    ElseIf ComboBox2.Text = " 5 seats" Then 'if combobox2 equals 5 seats then numseats equals 1' 
     numseats = 1 
    ElseIf ComboBox2.Text = " 6 seats" Then 'if combocbox2 equals 6 seats then numseats equals 0' 
     numseats = 0 
    End If 'ends the if statement' 
End Sub 

回答

0

您的代碼ISN」 t VBScript。儘管如此,所有基本方言都需要一個條件語句的If和Then之間的布爾表達式。

If ComboBox1.Text & firstseat & ":" & ComboBox2.Text & (firstseat + numseats - 1) Then 

需要反對的東西明智的連接字符串的比較。

+0

你能告訴我要寫什麼嗎? – Gigzr7 2014-09-26 09:36:26

+0

即時製作電影預訂系統 – Gigzr7 2014-09-26 09:36:56

相關問題