1
我有這個簡單的程序,給我一個錯誤。代碼如下所示從字符串轉換爲整數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
當我嘗試MessageBox的全名,地址和citystatezip它不斷給我一個錯誤說,它不能將地址轉換爲整數。我將所有這三個變量都聲明爲字符串,並在程序中將其運行時,我在這三個文本框中輸入了A B和C。