vbMarkO Posted September 30, 2005 Posted September 30, 2005 Here is some code I wrote earlier today.... It opens a text file loads it into an Array then I am counting number of chapters and number of verses in each chapter then displaying it in an rtb. However, I am getting a repeating of of this for example over and over this specific chapter chapter 1 has 10 verses its displaying like this in my rtb 1-10 1-10 1-10 repeating the above numerous times LOL I know I am missing something simple ... but for the life of me I am not seeing why this wont work Dim frPath As String Dim ReadString As String Dim myText As String Dim cntArr() As String frPath = "C:\Program Files\Dove Media\DoveSearch\" & fileListBox.SelectedItem Dim rFile As StreamReader Try If File.Exists(frPath) Then rFile = File.OpenText(frPath) ReadString = rFile.ReadToEnd() End If 'rtbText.Text = ReadString myText = ReadString cntArr = Split(ReadString, vbCrLf) Catch Finally rFile.Close() End Try Dim x As Integer = 1 Dim intChp As Integer Dim intVrs As Integer Dim counter As Integer For Each itm As String In cntArr If itm.StartsWith(x) Then counter = counter + 1 intVrs = counter displayText.Text = x & "-" & intVrs Else displayText.Text = displayText.Text & vbCrLf & x & "-" & intVrs End If Next vbMarkO Quote Visual Basic 2008 Express Edition!
vbMarkO Posted September 30, 2005 Author Posted September 30, 2005 Update; Thought I might add to my above post..... What I am counting to get the verses is the number of ones or twos or threes ect ect ect the chapter numbers as my text looks like this 1:1: Text 1:2: Text 1:3: Text 2:1: Text 2:2: Text 2:3: Text 2:4: Text 3:1: Text 3:2: Text and so on and on By counting the number of ones I have the exact number of verses for chapter one I have updated my code I am getting mixed results but not what I need so I am hoping someone might know how I should count this thing vbMarkO Quote Visual Basic 2008 Express Edition!
Machaira Posted September 30, 2005 Posted September 30, 2005 I'm willing to bet your problem lies here: displayText.Text = x & "-" & intVrs Have you tried stepping through the code line by line in the debugger? Quote Here's what I'm up to.
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.