Results 1 to 5 of 5

Thread: String Manipulation, please Help???

  1. #1

    Thread Starter
    New Member
    Join Date
    Apr 2002
    Posts
    8

    String Manipulation, please Help???

    I've got the following html code (string) within a Rich TextBox, can anyone tell me how I can search through this string to locate the substring "The winning balls for draw number 654 on 30 March 2002 were", and extract this to another Text box.

    Please note that this is an online VB application using Inet, so the substring (draw no. and date) will change every week.

    I'm assuming I need to use the InStr and Mid functions ???

    Thanks in advance: GT.


    <IMG SRC="images/results/onresu02.jpg" ALT="Saturday" WIDTH=152 HEIGHT=37 BORDER=0><br>
    The winning balls for draw number 654 on 30 March 2002 were:<BR CLEAR=ALL>
    <IMG SRC="images/results/numbers/num08.gif" ALT="08" WIDTH=53 HEIGHT=54 BORDER=0>
    <IMG SRC="images/results/numbers/num14.gif" ALT="14" WIDTH=53 HEIGHT=54 BORDER=0>
    <IMG SRC="images/results/numbers/num25.gif" ALT="25" WIDTH=53 HEIGHT=54 BORDER=0>
    <IMG SRC="images/results/numbers/num36.gif" ALT="36" WIDTH=53 HEIGHT=54 BORDER=0>
    <IMG SRC="images/results/numbers/num38.gif" ALT="38" WIDTH=53 HEIGHT=54 BORDER=0>
    <IMG SRC="images/results/numbers/num47.gif" ALT="47" WIDTH=53 HEIGHT=54 BORDER=0>

  2. #2
    Lively Member
    Join Date
    Nov 2000
    Location
    Sugar Grove, IL
    Posts
    99
    Off the top of my head

    VB Code:
    1. Private Sub Command1_Click()
    2.     Dim v As Variant
    3.     Dim x As Integer
    4.     v = Split(RichTextBox.Text, "images/results/numbers/")
    5.    
    6.     RichTextBox.Text = ""
    7.     For counter = 1 To UBound(v)
    8.          RichTextBox.Text = RichTextBox.Text & Mid(v(counter), 4, 2) & " "
    9.     Next counter
    10.  
    11. End Sub
    In case of a water landing, my head may be used as a flotation device.

  3. #3
    Member lordsty's Avatar
    Join Date
    Oct 2001
    Location
    mD, Us
    Posts
    58
    Give this a try....
    VB Code:
    1. position1 = InStr(1, RichTextBox1.Text, "The winning balls for draw number")
    2.   position2 = InStr(position1, RichTextBox1.Text, "were:")
    3.   tBox2.Text = Mid(RichTextBox1.Text, position1, (position2 + 4))
    4.   Wend

    lordsty
    Last edited by lordsty; Apr 5th, 2002 at 01:55 PM.

  4. #4
    DerFarm
    Guest
    Assuming that the exact string "The winning balls" will be
    replicated in every set:


    Code:
    xxx = instr(RTC,"The winning balls for draw number ") + 34
    yyy = instr(RTC," on ") 
    zzz = instr(RTC," were:")
    
    drawnumber = mid$(RCT,xxx,(yyy-xxx))
    drawdate=mid$(RTC, yyy+4,zzz-(yyy+4))
    
    qqq = instr(RTC,".gif")
    while qqq > 0
         ballnum = ballnum & mid$(RTC,qqq-2,2) & " "
         qqq = instr(qqq+1,RTC,".gif")
    wend
    where RTC = RichTextstring

    at the end you should have

    drawnumber = "654"
    drawdate= "30 March 2002"
    ballnum="08 14 25 36 38 47"

    you might have to play with +1 or -1 on the ranges, the problem
    begets fencepost problems all over the place.

    HTH

  5. #5
    PowerPoster Arc's Avatar
    Join Date
    Sep 2000
    Location
    Under my rock
    Posts
    2,336
    Or you can try this method

    VB Code:
    1. Private Sub Command1_Click()
    2. Dim Stren() As String, Stren2() As String, Number1() As String
    3. Dim Number2() As String, Number3() As String, Number4() As String
    4. Dim Number5() As String, Number6() As String
    5. Stren = Split(Text1, ">")
    6. Stren2 = Split(Stren(2), ":")
    7. Number1 = Split(Stren(3), """")
    8. Number2 = Split(Stren(4), """")
    9. Number3 = Split(Stren(5), """")
    10. Number4 = Split(Stren(6), """")
    11. Number5 = Split(Stren(7), """")
    12. Number6 = Split(Stren(8), """")
    13. MsgBox Stren2(0) & ": " & Number1(3) & "," & Number2(3) & "," & Number3(3) & "," & Number4(3) & "," & Number5(3) & "," & Number6(3)
    14. End Sub
    -We have enough youth. How about a fountain of "Smart"?
    -If you can read this, thank a teacher....and since it's in English, thank a soldier.


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