I'm try to do a simple program for class and I am having troubles. The program in a pinch is suppose to prompt you for a city, and state. Then when you click display it should display only the city in a message box. For instance if i type "Tampa, Florida" in the text box it should return "Tampa" in a message box. Does anyone know how to do this? I was under the impression I needed to use the trimend method, but do not know if that is the correct way. My current code looks along the lines of the following:
Private Sub btnDisplay_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnDisplay.Click
'displays the city name
'declare variables
Dim strAddress As String
Dim strCity As String
'assign input to a variable
strAddress = Me.txtAddress.Text
'display the city name
strCity = Me.txtAddress.Text.TrimEnd()
MessageBox.Show(strCity, "City Name", MessageBoxButtons.OK, _
MessageBoxIcon.Information, MessageBoxDefaultButton.Button1)
End Sub
Any advice/code would be appreciated. Thanks, Correy.
Private Sub btnDisplay_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnDisplay.Click
'displays the city name
'declare variables
Dim strAddress As String
Dim strCity As String
'assign input to a variable
strAddress = Me.txtAddress.Text
'display the city name
strCity = Me.txtAddress.Text.TrimEnd()
MessageBox.Show(strCity, "City Name", MessageBoxButtons.OK, _
MessageBoxIcon.Information, MessageBoxDefaultButton.Button1)
End Sub
Any advice/code would be appreciated. Thanks, Correy.