Results 1 to 8 of 8

Thread: [RESOLVED] replacing static url variables 'within a sub' with Textbox input

  1. #1

    Thread Starter
    Addicted Member jalexander's Avatar
    Join Date
    Jan 2011
    Location
    Memphis, TN
    Posts
    160

    Red face [RESOLVED] replacing static url variables 'within a sub' with Textbox input

    Alright in my last post, dunfiddlin helped me figure out how to pause this Sub (which is ran in/by a background worker)
    In this post I'm trying to figure out how to replace URL variables..with 'textboxs' i can edit via my form.
    Alright so here is my code...and I want to replace some of the url variables with TextBox's incase I want to collect names just in a certain contest thread. I did figure out how to place a Textbox for the # of seconds pausing though LoL :goose:

    Code:
        Private Sub ParseUsers()
            Dim pageSrc As String = GetStuff("http://www.my-forum.com/my-search/index.htm?get_forum_id_sub=11&thread_id=22&b=1")
            Dim maxPages As Integer = GetMaxPages(pageSrc)
            ProgressBar1.Maximum = maxPages
            Profilelist.AddRange(ExtractUsers(pageSrc))
            For i As Integer = 2 To maxPages
                pageSrc = GetStuff("http://www.my-forum.com/my-search/index.htm?get_forum_id_sub=11&thread_id=22&b=" & i.ToString)
                Profilelist.AddRange(ExtractUsers(pageSrc))
                ProgressBar1.Value = i
                Dim t As UInt64 = Now.Ticks
                Do Until Now.Ticks - t >= TextBox3.Text * 10 ^ 7 'where TextBox3.Text is required delay in seconds
                Loop
            Next
            IO.File.WriteAllLines("USERS.txt", Profilelist.ToArray)
        End Sub
    I don't know how to do this spacing/context wise...but here's what I'm wanting to replace

    Code:
    ?get_forum_id_sub=11&  (replace just the #11 with TextBox1.Text)
    &thread_id=22&  (replace just the #22 with TextBox2.Text)
    Last edited by jalexander; Sep 2nd, 2012 at 12:09 AM. Reason: resolved
    dim jenn as geek = true
    Learning ~ Visual Basic 2010 ~ in free time between college/work -
    currently looking for a 'programming buddy' / 'coder friend' / and or 'mentor'. p.m. me if you
    have ANY free time AT ALL I'm like 33% of a novice level ~ willing 2 listen/learn +
    i am totally super motivated & promise to make an effffin amazing protege!!! #swag

    | -_-_- -_-_- |
    ...W.T..F!?.....
    ||| Matter on the atomic/quantum level isn't solid or even matter at all. It can also exist in at least 2 places simultaneously (demonstrated in lab). It's position can only be established when it's actually observed. If we turn our back on it... it goes back to a wave form. History show's that every previous generation (since the beginning of time) got almost everything wrong. Then it might very well stand to reason that up is down & right can be wrong. Admit it.. our combined perception of reality is just that, we know absolutely nothing of actual reality & to think we do is simply subscribing to a "ignorance is bliss" mantra |||

  2. #2
    PowerPoster
    Join Date
    Sep 2006
    Location
    Egypt
    Posts
    2,579

    Re: beginners help: replacing static url variables 'within a sub' with Textbox input

    Pass TextBox1.Text and TextBox2.Text as parameters

    Code:
        Private Sub ParseUsers(ByVal id1 As String, ByVal id2 As String)
            Dim pageSrc As String = GetStuff("http://www.my-forum.com/my-search/index.htm?get_forum_id_sub=" & id1 & "&thread_id=" & id2 & "&b=1")
            Dim maxPages As Integer = GetMaxPages(pageSrc)
            ProgressBar1.Maximum = maxPages
            Profilelist.AddRange(ExtractUsers(pageSrc))
            For i As Integer = 2 To maxPages
                pageSrc = GetStuff("http://www.my-forum.com/my-search/index.htm?get_forum_id_sub=" & id1 & "&thread_id=" & id2 & "&b=" & i.ToString)
                Profilelist.AddRange(ExtractUsers(pageSrc))
                ProgressBar1.Value = i
                Dim t As UInt64 = Now.Ticks
                Do Until Now.Ticks - t >= TextBox3.Text * 10 ^ 7 'where TextBox3.Text is required delay in seconds
                Loop
            Next
            IO.File.WriteAllLines("USERS.txt", Profilelist.ToArray)
        End Sub



  3. #3

    Thread Starter
    Addicted Member jalexander's Avatar
    Join Date
    Jan 2011
    Location
    Memphis, TN
    Posts
    160

    Re: beginners help: replacing static url variables 'within a sub' with Textbox input

    Do you mean....like this?

    Code:
        Private Sub ParseUsers(ByVal TextBox1.Text As String, Byval TextBox2.Text As String)
            Dim pageSrc As String = GetStuff("http://www.my-forum.com/my-search/index.htm?get_forum_id_sub=" & TextBox1.text & "&thread_id=" & TextBox2.text & "&b=1")
            Dim maxPages As Integer = GetMaxPages(pageSrc)
            ProgressBar1.Maximum = maxPages
            Profilelist.AddRange(ExtractUsers(pageSrc))
            For i As Integer = 2 To maxPages
                pageSrc = GetStuff("http://www.my-forum.com/my-search/index.htm?get_forum_id_sub=" & TextBox1.text & "&thread_id=" & TextBox2.text & "&b=" & i.ToString)
                Profilelist.AddRange(ExtractUsers(pageSrc))
                ProgressBar1.Value = i
                Dim t As UInt64 = Now.Ticks
                Do Until Now.Ticks - t >= TextBox3.Text * 10 ^ 7 'where TextBox3.Text is required delay in seconds
                Loop
            Next
            IO.File.WriteAllLines("USERS.txt", Profilelist.ToArray)
        End Sub
    Or do you mean I should re-name Textbox1 to id1 under the 'properties' window in vs2010.
    Or do you mean like to 'declare' id1 as TextBox1.text under Public Class Form1
    Sorry I'm not quite sure what 'as parameters' means yet. I'm still a total newbie
    dim jenn as geek = true
    Learning ~ Visual Basic 2010 ~ in free time between college/work -
    currently looking for a 'programming buddy' / 'coder friend' / and or 'mentor'. p.m. me if you
    have ANY free time AT ALL I'm like 33% of a novice level ~ willing 2 listen/learn +
    i am totally super motivated & promise to make an effffin amazing protege!!! #swag

    | -_-_- -_-_- |
    ...W.T..F!?.....
    ||| Matter on the atomic/quantum level isn't solid or even matter at all. It can also exist in at least 2 places simultaneously (demonstrated in lab). It's position can only be established when it's actually observed. If we turn our back on it... it goes back to a wave form. History show's that every previous generation (since the beginning of time) got almost everything wrong. Then it might very well stand to reason that up is down & right can be wrong. Admit it.. our combined perception of reality is just that, we know absolutely nothing of actual reality & to think we do is simply subscribing to a "ignorance is bliss" mantra |||

  4. #4
    PowerPoster
    Join Date
    Sep 2006
    Location
    Egypt
    Posts
    2,579

    Re: beginners help: replacing static url variables 'within a sub' with Textbox input

    Leave the sub as it is
    Code:
        Private Sub ParseUsers(ByVal id1 As String, ByVal id2 As String)
            Dim pageSrc As String = GetStuff("http://www.my-forum.com/my-search/index.htm?get_forum_id_sub=" & id1 & "&thread_id=" & id2 & "&b=1")
            Dim maxPages As Integer = GetMaxPages(pageSrc)
            ProgressBar1.Maximum = maxPages
            Profilelist.AddRange(ExtractUsers(pageSrc))
            For i As Integer = 2 To maxPages
                pageSrc = GetStuff("http://www.my-forum.com/my-search/index.htm?get_forum_id_sub=" & id1 & "&thread_id=" & id2 & "&b=" & i.ToString)
                Profilelist.AddRange(ExtractUsers(pageSrc))
                ProgressBar1.Value = i
                Dim t As UInt64 = Now.Ticks
                Do Until Now.Ticks - t >= TextBox3.Text * 10 ^ 7 'where TextBox3.Text is required delay in seconds
                Loop
            Next
            IO.File.WriteAllLines("USERS.txt", Profilelist.ToArray)
        End Sub
    Then pass TextBox1.Text and TextBox2.Text when you call it, like this
    Code:
    ParseUsers(TextBox1.Text, TextBox2.Text)



  5. #5
    PowerPoster
    Join Date
    Sep 2006
    Location
    Egypt
    Posts
    2,579

    Re: beginners help: replacing static url variables 'within a sub' with Textbox input

    Double post deleted...
    Last edited by 4x2y; Aug 31st, 2012 at 08:07 PM.



  6. #6

    Thread Starter
    Addicted Member jalexander's Avatar
    Join Date
    Jan 2011
    Location
    Memphis, TN
    Posts
    160

    Re: beginners help: replacing static url variables 'within a sub' with Textbox input

    Ok so leave it exactly as you wrote it...with id1 & id2

    Then in this code....

    Code:
       Private Sub BackgroundWorker1_DoWork(ByVal sender As System.Object, ByVal e As System.ComponentModel.DoWorkEventArgs) Handles BackgroundWorker1.DoWork
            ParseMembers()
        End Sub
    Your saying to simply change it to....

    Code:
       Private Sub BackgroundWorker1_DoWork(ByVal sender As System.Object, ByVal e As System.ComponentModel.DoWorkEventArgs) Handles BackgroundWorker1.DoWork
            ParseUsers(TextBox1.Text, TextBox2.Text)
        End Sub
    And it will then be working & passing the #'s i manually put into my textboxs?
    How does it know that TextBox1.Text is now id1? I'm just confused I guess. But I will definitely try this out & thank you so much!!
    dim jenn as geek = true
    Learning ~ Visual Basic 2010 ~ in free time between college/work -
    currently looking for a 'programming buddy' / 'coder friend' / and or 'mentor'. p.m. me if you
    have ANY free time AT ALL I'm like 33% of a novice level ~ willing 2 listen/learn +
    i am totally super motivated & promise to make an effffin amazing protege!!! #swag

    | -_-_- -_-_- |
    ...W.T..F!?.....
    ||| Matter on the atomic/quantum level isn't solid or even matter at all. It can also exist in at least 2 places simultaneously (demonstrated in lab). It's position can only be established when it's actually observed. If we turn our back on it... it goes back to a wave form. History show's that every previous generation (since the beginning of time) got almost everything wrong. Then it might very well stand to reason that up is down & right can be wrong. Admit it.. our combined perception of reality is just that, we know absolutely nothing of actual reality & to think we do is simply subscribing to a "ignorance is bliss" mantra |||

  7. #7
    PowerPoster
    Join Date
    Feb 2012
    Location
    West Virginia
    Posts
    14,206

    Re: beginners help: replacing static url variables 'within a sub' with Textbox input

    It knows because you are telling it so
    Code:
    Private Sub ParseUsers(ByVal id1 As String, ByVal id2 As String)
    It expects 2 string paramaters in your case this would be the text property of the textboxes you want to use. It could be a literal as well or any other string variable in any case they will be known to the sub as id1 and id2 no matter what the source because that is in the definition of the sub.

  8. #8

    Thread Starter
    Addicted Member jalexander's Avatar
    Join Date
    Jan 2011
    Location
    Memphis, TN
    Posts
    160

    Re: beginners help: replacing static url variables 'within a sub' with Textbox input

    Quote Originally Posted by DataMiser View Post
    It knows because you are telling it so
    Code:
    Private Sub ParseUsers(ByVal id1 As String, ByVal id2 As String)
    It expects 2 string paramaters in your case this would be the text property of the textboxes you want to use. It could be a literal as well or any other string variable in any case they will be known to the sub as id1 and id2 no matter what the source because that is in the definition of the sub.
    Of course it works aweeeesome!

    Thank you guys all so much!!!!
    Last edited by jalexander; Sep 2nd, 2012 at 04:24 PM. Reason: RESOLVED
    dim jenn as geek = true
    Learning ~ Visual Basic 2010 ~ in free time between college/work -
    currently looking for a 'programming buddy' / 'coder friend' / and or 'mentor'. p.m. me if you
    have ANY free time AT ALL I'm like 33% of a novice level ~ willing 2 listen/learn +
    i am totally super motivated & promise to make an effffin amazing protege!!! #swag

    | -_-_- -_-_- |
    ...W.T..F!?.....
    ||| Matter on the atomic/quantum level isn't solid or even matter at all. It can also exist in at least 2 places simultaneously (demonstrated in lab). It's position can only be established when it's actually observed. If we turn our back on it... it goes back to a wave form. History show's that every previous generation (since the beginning of time) got almost everything wrong. Then it might very well stand to reason that up is down & right can be wrong. Admit it.. our combined perception of reality is just that, we know absolutely nothing of actual reality & to think we do is simply subscribing to a "ignorance is bliss" mantra |||

Tags for this Thread

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