Hi im trying to use a 2 combo boxes each with a list of 7 cities these need to link up with numbers in a stream reader to give a total distance if any1 can help it would be much appriciated. Below is my attempt at the codeCode:Public Class frmDist Private Sub frmDist_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Dim rowcolumn(7, 7) As Integer Dim sr As IO.StreamReader = IO.File.OpenText("Distance.Txt") Dim row, col As Integer For row = 1 To 7 For col = 1 To 7 rowcolumn(row, col) = CInt(sr.ReadLine) Next Next sr.Close() End Sub Private Sub btnDistance_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnDistance.Click Dim rowcolumn(7, 7) As Integer Dim sr As IO.StreamReader = IO.File.OpenText("Distance.Txt") Dim row, col As Integer Dim Southampton, Edinburgh, London, Cardiff, Birmingham, Newcastle, Manchester As String Southampton = Convert.ToInt32(1) Edinburgh = Convert.ToInt32(2) London = Convert.ToInt32(3) Cardiff = Convert.ToInt32(4) Birmingham = Convert.ToInt32(5) Newcastle = Convert.ToInt32(6) Manchester = Convert.ToInt32(7) For row = 1 To 7 For col = 1 To 7 rowcolumn(row, col) = CInt(sr.ReadLine) Next Next sr.Close() row = (cmb1.Text) col = (cmb2.Text) If (row >= 1 And row <= 7) And (col >= 1 And col <= 7) Then lblDistance.Text = ("The total milage of the return journey is ") & CStr(rowcolumn(cmb1.Text, cmb2.Text)) & (" miles.") End If End Sub End Class




Reply With Quote