2013-11-02 3 views
1

나는이 간단한 프로그램을 통해 오류가 발생했습니다. 나는 전체 이름, 주소를 메시지 박스하려고하고 나에게 그것을 정수로 주소를 변환 할 수 없다는 오류를주는 유지 citystatezip 때문자열에서 정수로의 변환 vb.net

Private Sub btnProcess_Click(sender As Object, e As EventArgs) Handles btnProcess.Click 
    Dim FullName As String = "" 
    Dim Address As String = "" 
    Dim CityStateZip As String = "" 
    Dim Stoves As Integer 
    Dim Refrigerators As Integer 
    Dim Dishwashers As Integer 

    INPUT_DATA(FullName, Address, CityStateZip, Stoves, Refrigerators, Dishwashers) 
    MsgBox(FullName, Address, CityStateZip) 

End Sub 
Sub INPUT_DATA(ByRef Name As String, ByRef Address As String, ByRef CSZ As String, ByRef Stoves As Integer, ByRef Refrigerators As Integer, ByRef Dishwashers As Integer) 
    If txtName.Text = "" Then 
     Name = InputBox("Please enter a name!") 
    Else 
     Name = txtName.Text 
    End If 
    If txtAddress.Text = "" Then 
     Address = InputBox("Please enter an address!") 
    Else 
     Address = txtAddress.Text 
    End If 
    If txtCSZ.Text = "" Then 
     CSZ = InputBox("Please enter City, State, Zip!") 
    Else 
     CSZ = txtCSZ.Text 
    End If 
End Sub 

을 다음과 같이 코드입니다. 나는이 세 변수를 모두 문자열로 선언했고 프로그램을 실행했을 때 세 개의 텍스트 상자에 A B와 C를 입력했습니다.

답변

2

(VS는 인텔리을 통해 표시됩니다으로)있는 MsgBox의 구문은 다음과 같습니다

MsgBox (Prompt, Optional ByVal Buttons As Microsoft.VisualBasic.MsgBoxStyle = _ 
     OkOnly, Optional ByVal Title As Object = Nothing) 

이있는 MsgBox를 호출 할 때 두 번째 매개 변수는 스타일을 나타내는 정수이어야한다. 사용해보기 :

MsgBox (FullName & " - " & Address & " - " & CityStateZip) 

또는 원하는 경우 줄 바꿈을 추가하십시오.

관련 문제