Jump to content
Xtreme .Net Talk

How can I reduce this to One button Click Instead of repeated Clicks


Recommended Posts

Posted

Heres my code

 

I am having to Click the button over and over until the variable myInt > UBound(myChap)

 

how can I make it so it iterates through until myINt is greater than UBound(myChap)

 

Public myInt As Integer
   Public myChap() As String


   Private Sub cleanSweep()
       Dim strText As String
       strText = "1:1: Line of Text:" & vbCrLf & "1:2: Line of Text:" & vbCrLf & "1:3: Line: of Text" _
       & vbCrLf & "2:1: Line of Text" & vbCrLf & "2:2: Line of: Text" & vbCrLf & "2:3: Line of Text:" & vbCrLf & "2:4 Line of Text"
       Dim myArr() As String

       Dim strChap As String
       myArr = Split(strText, vbCrLf)
       ReDim Preserve myArr(0 To UBound(myArr))
       For i As Integer = 0 To UBound(myArr)
           For Each itm As String In myArr
               If itm.StartsWith(i & ":1") Then
                   strChap = strChap & itm & vbCrLf
                   myChap = Split(strChap, vbCrLf)
                   ReDim Preserve myChap(0 To UBound(myChap))
               End If
           Next
       Next
       Dim Vi As Integer
       Dim Ci As Integer
       Dim myCount As Integer
       Dim strVerse As String

       myCount = 0
       Ci = myInt
       If myInt > UBound(myChap) Then

           Return
       Else
           myInt = myInt + 1

       End If

       For Each itm As String In myArr
           If itm.StartsWith(Ci) Then

               myCount = myCount + 1
               Vi = myCount
               If itm.StartsWith(Ci & ":" & Vi & ":") Then

                   strVerse = strVerse & itm.Replace(":" & Vi & ":", ">" & Vi & ">") & vbCrLf

               End If
           End If
           Label2.Text = myCount
       Next

       If TextBox1.Text <> "" Then
           TextBox1.Text = TextBox1.Text & strVerse & vbCrLf
       Else
           TextBox1.Text = strVerse
       End If


       Label1.Text = UBound(myChap)

   End Sub
   Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
      cleanSweep()

   End Sub

   Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
       myInt = 1
   End Sub

vbMarkO

Visual Basic 2008 Express Edition!

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...