[Help] Grab usernames from multiline textbox

Discussion in 'Programming General' started by matto, Jan 24, 2009.

[Help] Grab usernames from multiline textbox
  1. Unread #1 - Jan 24, 2009 at 7:28 AM
  2. matto
    Joined:
    Apr 2, 2007
    Posts:
    89
    Referrals:
    0
    Sythe Gold:
    0

    matto Member

    [Help] Grab usernames from multiline textbox

    Hi. I'm trying to make a highscore lookup which grabs a list of usernames from a listbox or multiline textbox, and if the total level is above 900, it puts the username in listbox/multiline textbox 2.

    So far, I have managed to get a username from a textbox, then display a message in a label depending on what the total level is.

    Here's my code so far:

    Code:
        Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
            Dim name As String = TextBox1.Text
            Dim src As String 'Declares the variable that will hold the source code
            Dim net As New Net.WebClient() 'Creates a new instance of a WebClient
            src = net.DownloadString("http://hiscore.runescape.com/index_lite.ws?player=" + name) 'Downloads the html source and puts it in the variable src
            Dim tmp() As String = src.Split(",")
            tmp = src.Split(",")
    
            If (tmp(1) > 900) Then
    
                Label2.Text = tmp(1)
    
            ElseIf src.IndexOf("Error 404") > -1 Then
                Label2.Text = "Error"
    
            Else
                Label2.Text = "Total level is below 900"
    
            End If
        End Sub
    
    Any help would be appreciated. Thanks
     
  3. Unread #2 - Jan 24, 2009 at 9:55 AM
  4. drainingpower
    Joined:
    Jan 15, 2008
    Posts:
    1,166
    Referrals:
    0
    Sythe Gold:
    0

    drainingpower Guru

    [Help] Grab usernames from multiline textbox

    You may want to do that on a backgroundworker, because if you experience lag when it navigates, it doesn't lag when the webclient navigates and it's prety useful. Just what I would do in beggining of the backgroundworker is to put checking for illegal cross threads to false, I know that isn't really professional but it gets the job done. :)
     
  5. Unread #3 - Jan 24, 2009 at 11:53 AM
  6. matto
    Joined:
    Apr 2, 2007
    Posts:
    89
    Referrals:
    0
    Sythe Gold:
    0

    matto Member

    [Help] Grab usernames from multiline textbox

    Uhm....I have no idea what a backgroundworker is lol, I'm a noob at vb.net
     
  7. Unread #4 - Jan 25, 2009 at 8:32 AM
  8. Stuart
    Joined:
    May 5, 2005
    Posts:
    1,580
    Referrals:
    2
    Sythe Gold:
    10

    Stuart Guru
    Banned

    [Help] Grab usernames from multiline textbox

    Something like this?

    Code:
        Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
            Dim num As Integer = 0
            Dim name As String = TextBox1.Text
            Dim src As String 'Declares the variable that will hold the source code
            Dim net As New Net.WebClient() 'Creates a new instance of a WebClient
            src = net.DownloadString("http://hiscore.runescape.com/index_lite.ws?player=" + name) 'Downloads the html source and puts it in the variable src
            Dim tmp() As String = src.Split(",")
            tmp = src.Split(",")
    
            Do
                If (tmp.Length < 900) Then
                    ' add to first listbox here
                    Label2.Text = "Total level is below 900"
                ElseIf src.IndexOf("Error 404") > -1 Then
                    Label2.Text = "Error"
                Else
                    ' add to second listbox here
                End If
    
                num = num + 1
            Loop Until num = tmp.Length
        End Sub
    
     
  9. Unread #5 - Jan 25, 2009 at 9:41 AM
  10. matto
    Joined:
    Apr 2, 2007
    Posts:
    89
    Referrals:
    0
    Sythe Gold:
    0

    matto Member

    [Help] Grab usernames from multiline textbox

    ah ok, thanks :D

    now i need to find out how to load the usernames from a listbox
     
< Need help with Program | Making a runescape Client >

Users viewing this thread
1 guest


 
 
Adblock breaks this site