1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Help with the basics

Discussion in 'Visual Basic .NET' started by Jixor, Nov 18, 2012.

  1. Jixor

    Jixor Registered Member

    Joined:
    Jan 1, 2012
    Messages:
    86
    Likes Received:
    7
    Hello, needing a little help.

    I'm creating something using http web requests and iwant it to use different proxies.

    So I understand the following:

    Code:
    Dim myproxy As New WebProxy("http://1.1.1.1:80")
    But I would really like to populate the address section using an item from a listbox.

    When I do so, VB tells me off because I am trying to convert a string to a webproxy data type.

    Can anyone help?

    Thanks
     
  2. cgimaster

    cgimaster Power Member

    Joined:
    Jun 30, 2012
    Messages:
    525
    Likes Received:
    311
    Gender:
    Male
    just replace the "..." with the textbox value TextBox1.Text
     
  3. Jixor

    Jixor Registered Member

    Joined:
    Jan 1, 2012
    Messages:
    86
    Likes Received:
    7
    Thanks for the reply, I tried that except it was ListBox1.Items(x). It didn't work so I've now moved onto c# and it seems to be working so far!

    I should've went straight to c# in the first instance, silly me!
     
  4. cgimaster

    cgimaster Power Member

    Joined:
    Jun 30, 2012
    Messages:
    525
    Likes Received:
    311
    Gender:
    Male
    I am sorry I misread you LOL I was thinking u just wanted to know how to use the text box of whatever to fill it.

    To get the item from the listbox you need to use it like this:

    Code:
    listBox.Items(1).ToString()
     
  5. Jixor

    Jixor Registered Member

    Joined:
    Jan 1, 2012
    Messages:
    86
    Likes Received:
    7
    Yea I added the tostring() in aswell but it was still giving me trouble. I've obviously made a booboo so will probably go back to it so that I can put my mind at ease haha. But for now C# will be used.
     
  6. cgimaster

    cgimaster Power Member

    Joined:
    Jun 30, 2012
    Messages:
    525
    Likes Received:
    311
    Gender:
    Male
    Code:
        Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click
            ListBox1.Items.Add("127.0.0.1:80")
            ListBox1.Items.Add("127.0.0.1:3128")
            For x = 0 To ListBox1.Items.Count - 1
                Dim MyProxy As New WebProxy(ListBox1.Items(x).ToString())
            Next
    
            For Each item In ListBox1.Items
                Dim MyProxy As New WebProxy(item.ToString())
            Next item
        End Sub
    Works just fine for me.

    Don forget u also need "Imports System.Net"
     
    • Thanks Thanks x 2
    Last edited: Nov 18, 2012
  7. qrazy

    qrazy Senior Member

    Joined:
    Mar 19, 2012
    Messages:
    1,111
    Likes Received:
    1,712
    Location:
    Banana Republic
    Use the code from the above poster. BTW this thread has got nothing to do with HTTP WEB REQUEST, it's about how to access the string from the listbox. It's better if you post the title of the thread clear to get better help from people.
     
  8. cgimaster

    cgimaster Power Member

    Joined:
    Jun 30, 2012
    Messages:
    525
    Likes Received:
    311
    Gender:
    Male
    Have placed a sample with For Each and with For ;) they are both working, but If you are just starting with programming C# is way easier to understand and to use over vb.net.
     
  9. Jixor

    Jixor Registered Member

    Joined:
    Jan 1, 2012
    Messages:
    86
    Likes Received:
    7
    Thanks dude! Yea I think I was willing myself to make the switch to c#.

    Gave up on it tonight though. Just a quick question and I guess a bit off topic.

    Can you actually record a "site visit" with the http web request? I'm saying obviously yes, but it just seems a bit too easy? Either way I'm still doing alot of research on it. I've also ran a test so just waiting to see if it works now.
     
    Last edited: Nov 18, 2012
  10. cgimaster

    cgimaster Power Member

    Joined:
    Jun 30, 2012
    Messages:
    525
    Likes Received:
    311
    Gender:
    Male
    Well it depends on the site but if what you want is for instance, be able to open the site and navigate on it, there are several ways of doing it with http requests, but you might need to use a htmlparser to further gather other urls that you want it to interact with or forms, etc.
     
  11. w84it

    w84it Regular Member

    Joined:
    Jun 18, 2009
    Messages:
    442
    Likes Received:
    752
    Seems like you are trying to jump in the deep end without even knowing how to swim...
    Learn the language first then move on to the web stuff.