1

I have this simple program that is giving me an error. The code is as follows

    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

When I try to messagebox fullname, address and citystatezip it keeps giving me an error saying that it can't convert the address to an integer. I declared all three of those variables as strings and in the program when I ran it I entered A B and C in those three textboxes.

1 Answer 1

2

The syntax for MsgBox (as VS will show you via Intellisense) is:

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

When you call MsgBox your second parameter should be an Integer indicating the style. Try This:

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

or add linefeeds if you choose.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.