Results 1 to 4 of 4

Thread: [RESOLVED] help help help :0

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Sep 2006
    Posts
    91

    Resolved [RESOLVED] help help help :0

    i have 2 multiline textboxs textbox1,textbox2
    textbox1 contain text like this

    Code:
    I have to go now,i have a lot of work to do
    today i will finish it to get high score,i get high score towice
    the required code is to get the words betwain "i" and "to" in textbox2 to be like this
    Code:
    I have to
    i have a lot of work to
    i will finish it to

  2. #2
    Addicted Member
    Join Date
    Nov 2006
    Posts
    132

    Re: help help help :0

    So what exactly to you need help with? Everything???

    There are several ways to do this. Assuming this is a school assignment for a beginning class, you proabably will be using the Instr and Mid$ functions.

    Look those up and experiment with them, and you will learn how to do this.
    Last edited by woodyz; Dec 1st, 2006 at 10:20 PM.

  3. #3
    VB Guru ganeshmoorthy's Avatar
    Join Date
    Dec 2005
    Location
    Sharjah, United Arab Emirates
    Posts
    3,031

    Re: help help help :0

    try this...
    VB Code:
    1. Private Sub Command1_Click()
    2.     Dim iSPos As Integer
    3.     Dim iEPos As Integer
    4.     Dim iNextSPos As Integer
    5.     Dim iNextEPos As Integer
    6.     Dim iLength As Integer
    7.  
    8.     iNextSPos = 1
    9.     iNextEPos = 1
    10.     iLength = Len(Trim(Text1.Text))
    11.     Do While i <= iLength
    12.         iSPos = InStr(iNextSPos, Text1.Text, "I ", vbTextCompare)
    13.         If iSPos > 0 Then
    14.             iEPos = InStr(iNextEPos, Text1.Text, " to ")
    15.             If iEPos > 0 Then
    16.                 Text2.Text = Text2.Text & Mid(Text1.Text, iSPos, (iEPos + 3) - iSPos) & vbCrLf
    17.                 iNextSPos = iEPos + 3
    18.                 iNextEPos = iEPos + 3
    19.                 i = i + iEPos
    20.             Else
    21.                 i = i + 1
    22.             End If
    23.         Else
    24.             i = i + 1
    25.         End If
    26.     Loop
    27. End Sub
    If an answer to your question has been helpful, then please, Rate it!

    Have done Projects in Access and Member management systems using BioMetric devices, Smart cards and BarCodes.


  4. #4

    Thread Starter
    Lively Member
    Join Date
    Sep 2006
    Posts
    91

    Re: help help help :0

    Quote Originally Posted by ganeshmoorthy
    try this...
    VB Code:
    1. Private Sub Command1_Click()
    2.     Dim iSPos As Integer
    3.     Dim iEPos As Integer
    4.     Dim iNextSPos As Integer
    5.     Dim iNextEPos As Integer
    6.     Dim iLength As Integer
    7.  
    8.     iNextSPos = 1
    9.     iNextEPos = 1
    10.     iLength = Len(Trim(Text1.Text))
    11.     Do While i <= iLength
    12.         iSPos = InStr(iNextSPos, Text1.Text, "I ", vbTextCompare)
    13.         If iSPos > 0 Then
    14.             iEPos = InStr(iNextEPos, Text1.Text, " to ")
    15.             If iEPos > 0 Then
    16.                 Text2.Text = Text2.Text & Mid(Text1.Text, iSPos, (iEPos + 3) - iSPos) & vbCrLf
    17.                 iNextSPos = iEPos + 3
    18.                 iNextEPos = iEPos + 3
    19.                 i = i + iEPos
    20.             Else
    21.                 i = i + 1
    22.             End If
    23.         Else
    24.             i = i + 1
    25.         End If
    26.     Loop
    27. End Sub
    Code:
    Thanks for great help
    i changed it to be perfect with lines may contains more than one case of the condition


    VB Code:
    1. Dim TxT, IStr, ToStr, ILoc, ToLoc, GLoc, Strng
    2. BeStr = " i "
    3. ThisStr = " to "
    4. GLoc = 1
    5. TxT = Text1.Text
    6. For oop = 1 To (Len(TxT) - 1)
    7.     ILoc = InStr(GLoc, TxT, IStr, vbTextCompare)
    8.     If ILoc > 0 Then
    9.    
    10.         ToLoc = InStr(GLoc, TxT, ToStr, vbTextCompare)
    11.         If ToLoc > 0 Then
    12.             GLoc = ToLoc + 1
    13.             Strng = Mid$(Text1.Text, ILoc + 1, (ToLoc + 3) - ILoc)
    14.             Text2.Text = Text2.Text & Strng & vbnewline
    15.         Else
    16.         oop = oop + 1
    17.         End If
    18.     Else
    19.     oop = oop + 1
    20.     End If
    21. Next
    22. End Sub

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width