Basicly at the moment I’ve got a file being read in, and then lines in the file being counted (this will eventually help build and array to hold the data).
However at the moment it’s not counting the lines at all. I’m not sure what’s wrong with the code it looks fine to me. Hoping a fresh pair of eyes might point out what I’ve done wrong!
Code:Public Class MicroMouse Inherits System.Windows.Forms.Form Private MMDATA As System.IO.StreamReader Dim MMFile As String Private Sub BtnOpenFile_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnOpenFile.Click OFDMicroData.Title = "Locate Micro Mouse Source File" OFDMicroData.Filter = "MicroMouse TAB Seperated File (*.txt)| *.txt" If (OFDMicroData.ShowDialog() = DialogResult.OK) Then MMFile = OFDMicroData.FileName MMDATA = System.IO.File.OpenText(MMFile) LBOpenedFile.Text = MMFile Else MsgBox("Please Select a valid MicroMouse Data File", MsgBoxStyle.Exclamation, "File Not Selected") LBOpenedFile.Text = "Error No File Selected" End If LineCounter() End Sub Private Sub LineCounter() Dim Curline, Letter As String Dim i, CharsInFile, LineCount As Short LineCount = 0 CharsInFile = MMFile.Length For i = 0 To CharsInFile - 1 Letter = MMFile.Substring(i, 1) If Letter = Chr(13) Then LineCount += 1 i += 1 End If Next i LBcount.Text = LineCount End Sub End Class


LinkBack URL
About LinkBacks
Reply With Quote

