我有这个简单的程序给我一个错误。代码如下
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
当我尝试使用messagebox fullname,address和citystatezip时,它一直给我一个错误,说它无法将地址转换为整数。我将所有这三个变量都声明为字符串,当我运行它时,我在这三个文本框中输入了A B和C.
答案 0 :(得分:2)
MsgBox的语法(VS将通过Intellisense向您显示)是:
MsgBox (Prompt, Optional ByVal Buttons As Microsoft.VisualBasic.MsgBoxStyle = _
OkOnly, Optional ByVal Title As Object = Nothing)
当您调用MsgBox时,您的第二个参数应该是指示样式的Integer。试试这个:
MsgBox (FullName & " - " & Address & " - " & CityStateZip)
或如果您选择添加换行符。