Click here to Skip to main content
15,881,870 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Can someone please help me out. I want to generate bulk tinyurl from one main url like:

Main - www.google.com
Tinyurl:
1. http://tinyurl.com/fdfff
2. http://tinyurl.com/dfdff
up to user defined value (min:1 and max 100 through numericupdown control)

I have a code but it only generate one url:

VB
Private Function shrink(ByVal url As String) As String
        Dim enteredURL As String
        enteredURL = "http://tinyurl.com/api-create.php?url=" + url.ToLower
        Dim strURL As String = enteredURL
        Dim objWebRequest As System.Net.HttpWebRequest
        Dim objWebResponse As System.Net.HttpWebResponse
        Dim streamReader As System.IO.StreamReader
        Dim strHTML As String
        Dim sendString As String
        objWebRequest = CType(System.Net.WebRequest.Create(strURL), System.Net.HttpWebRequest)
        objWebRequest.Method = "GET"
            objWebResponse = CType(objWebRequest.GetResponse(), System.Net.HttpWebResponse)
            streamReader = New System.IO.StreamReader(objWebResponse.GetResponseStream)
            strHTML = streamReader.ReadToEnd
        Return (strHTML)
            streamReader.Close()
            objWebResponse.Close()
            objWebRequest.Abort()
    End Function


VB
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
       ListBox2.Items.Clear()
       ListBox3.Items.Clear()
       Label4.Text = "Working ..."
       ProgressBar1.Value = 0
       ProgressBar1.Maximum = ListBox1.Items.Count
       Threading.Thread.Sleep(1000)
       For i As Integer = 0 To ListBox1.Items.Count - 1
           Try
               ListBox3.Items.Add(ListBox1.Items.Item(i).ToString)
               ListBox2.Items.Add(shrink(ListBox1.Items.Item(i).ToString))
               Threading.Thread.Sleep(1000)
               ProgressBar1.Value += 1
           Catch t As Exception
               MsgBox(t.Message)
           End Try
       Next
       ListBox1.Items.Clear()
       ProgressBar1.Value = 0
       Label4.Text = ""
   End Sub
Posted
Comments
Richard MacCutchan 8-Sep-15 4:17am    
Use your debugger to step through the code and find out where it stops. You would also do better to use proper meaningful names for your objects rather than the deafult ListBox1, 2 ...

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900