Results 1 to 5 of 5

Thread: Im going to be very specific... (string finding/manipulation)

  1. #1

    Thread Starter
    Lively Member
    Join Date
    May 2003
    Posts
    98

    Im going to be very specific... (string finding/manipulation)

    Alrighty,

    I am ALMOST finsihed with the current program i am writing, i need to do one simple thing:

    I have 51 of these: http://vnboards.ign.com/user.asp?usr=<number> strings in a textbox, Now, im looking to use ALL 51 of thoes strings, but first i need to recognize them, I know exactally how to find the FIRST string, and take what i need from it, but i cant say the same for all the others... im using this to find the first string right now:

    Code:
    Function finduid()
    Dim iEnd As Integer
            spam = TextBox2.Text
            Dim inner As String = "/user.asp?usr="
            uid = (spam.Substring(spam.IndexOf(inner), 25))
            uid = (Mid(uid, 15, 25))
            iEnd = uid.LastIndexOf(">") - 1
            uid = uid.Substring(0, iEnd - 0).Trim
            Trim(uid)
        End Function
    But i have no idea how to even begin to search for the next string, or the string after that...


    Also, how could i check for repeat strings?


    Any help anyone could offer would be great!

    thanks a ton

  2. #2
    Frenzied Member dynamic_sysop's Avatar
    Join Date
    Jun 2003
    Location
    Ashby, Leicestershire.
    Posts
    1,142
    ok i'm assuming you have the items listed in the textbox below eachother , like this :
    http://vnboards.ign.com/user.asp?usr=1
    http://vnboards.ign.com/user.asp?usr=2
    http://vnboards.ign.com/user.asp?usr=3

    with that in mind you can do this :
    VB Code:
    1. Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
    2.         Dim i As Integer
    3.         Dim strString As String
    4.         For i = 0 To TextBox1.Lines.Length - 1
    5.             strString = Split(TextBox1.Lines(i).ToString, "=")(1)
    6.             MsgBox("the user's number is: " & strString)
    7.         Next
    8.  
    9.     End Sub
    ~
    if a post is resolved, please mark it as [Resolved]
    protected string get_Signature(){return Censored;}
    [vbcode][php] please use code tags when posting any code [/php][/vbcode]

  3. #3

    Thread Starter
    Lively Member
    Join Date
    May 2003
    Posts
    98
    Hmmm, will split return all the instances of that string?

    Also if it makes a difference, im pulling all of this information out of an HTML page

    Oh didnt see that, no, they are not listed below eachother
    Last edited by Azkar; Jun 28th, 2003 at 07:45 PM.

  4. #4
    Fanatic Member
    Join Date
    Jun 2001
    Posts
    521
    Use regular expressions!
    VB Code:
    1. For Each m As System.Text.RegularExpressions.Match In _
    2.             System.Text.RegularExpressions.Regex.Matches(sSearch, "(?<=\?usr=)-?\d+\.?\d*")
    3.  
    4.             Process(m.Value)
    5.         Next
    sSearch is the string you want to search, and Process is just a function that does something with the value. (You can just use it in code and not call a function...) That regular expression will match negative numbers and reals, as well as plain old positive integers.
    I have two simple requests: 1) Use useful and specific topics. 2) Modify your topic to include [Resolved] when you problem has been resolved. Both of these make the bulletin boards more useful and efficient. Thanks.

  5. #5

    Thread Starter
    Lively Member
    Join Date
    May 2003
    Posts
    98
    'Ah hmmm, ill play around with that tomorrow, thanks
    Last edited by Azkar; Jun 28th, 2003 at 10:19 PM.

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