2014-09-26 2 views
0

"문자열"행 E1 : 2 자리 2 "에서 '부울'유형으로의 변환이 올바르지 않습니다.""문자열"행 E1 : 2 자리 2 "에서 '부울'유형으로의 변환이 유효하지 않습니다."

도와주세요 시네마 예약 시스템을 만들고 있습니다.

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 '나는 좌석을 예약 할 수와 좌석 1-6 좌석과 AE 행 양식 정의의 가용성을 확인해야 t VBScript. 그럼에도 불구하고, 모든 Basic Dialect는 조건문의 If와 Then 사이에 부울 표현을 필요로합니다. 귀하의

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

는 재치있는 무언가에 대한 연결된 문자열의 비교를 필요로한다.

+0

쓸 내용에 대해 조언 해 줄 수 있습니까? – Gigzr7

+0

영화 예약 시스템 만들기 – Gigzr7

관련 문제