Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim cities() As String = {"Canton", "Cincinnati", "Cleveland", "Columbus", "Dayton", "Toledo", "Youngstown"}
Dim city1 As String = TextBox1.Text
Dim city2 As String = TextBox2.Text
Dim cityVal As Integer = 0
Dim xVal As Integer = 0
Dim yVal As Integer = 0
Dim mi As Integer
Dim miles(7, 7) As Integer
Dim randomGenerator As New Random
While cityVal <= 6
For check1 As Integer = 0 To check1 <= 6
cityVal = city1.CompareTo(cities(check1))
If cityVal <= 6 Then
xVal = check1
check1 = 7
For check2 As Integer = 0 To check2 <= 6
cityVal = city2.CompareTo(cities(check2))
If cityVal <= 6 Then
yVal = check2
check2 = 7
Else
MsgBox("Invalid City!", MsgBoxStyle.Exclamation)
End If
Next check2
Else
MsgBox("Invalid City!", MsgBoxStyle.Exclamation)
End If
Next check1
cityVal = 7
End While
For x As Integer = 0 To 6
For y As Integer = 0 To 6
If x = y Then
miles(x, y) = 0
End If
mi = randomGenerator.Next(1, 1000)
miles(x, y) = mi
miles(y, x) = miles(x, y)
Next
Next
Dim distance As Integer
distance = miles(xVal, yVal)
TextBox3.Text = distance
End Sub
End Class