anault24
asked on
Visual Basic Zip Solution Ch. 8 Lesson B Exercise 15
I am coding a Button that displays the shipping charge when you enter a zip code. To be valid, the ZIP code must contain exactly 5 digits, and the first three digits must be either "605" or "606". The shipping charge for "605" ZIP codes is $25. The shipping charge for "606" ZIP codes is $30. Display an appropriate message if the ZIP code is invalid. I am having trouble finding a way to have the right price show up for the two different zip codes. Can anyone help me out?
Private Sub btnDisplay_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnDisplay.Click
' variable for shipping charge
Dim strZip As String
'remove any leading and trailing spaces
strZip = txtZip.Text.Trim
' shipping price for zip code starting with 605
If strZip Like "60[5-6]##" Then
lblShipping.Text = "$25"
Else
MessageBox.Show("The Zip is invalid.", _
"Zip Code", MessageBoxButtons.OK, _
MessageBoxIcon.Information )
End If
End Sub
Private Sub btnDisplay_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnDisplay.Click
' variable for shipping charge
Dim strZip As String
'remove any leading and trailing spaces
strZip = txtZip.Text.Trim
' shipping price for zip code starting with 605
If strZip Like "60[5-6]##" Then
lblShipping.Text = "$25"
Else
MessageBox.Show("The Zip is invalid.", _
"Zip Code", MessageBoxButtons.OK, _
MessageBoxIcon.Information
End If
End Sub
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.