Click here to Skip to main content
15,896,201 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I want to add a loop with variables to a webrequest code :
VB
rivate Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
        Dim i As New Integer
        For i = 200 To 234
            Dim request As WebRequest = WebRequest.Create("http://cpanel.*******.gr/api/*********/dlr.php?id=i&uname=********&pass=********")

            ' Set the Method property of the request to POST.
            request.Method = "POST"


is this the right syntax for id? I want to add the int32 vb net 'i' variable to the webrequest
VB
*********/dlr.php?id=i&
Posted
Updated 18-Jun-15 22:46pm
v3

1 solution

try as below
VB
Dim request As WebRequest = WebRequest.Create("http://cpanel.*******.gr/api/*********/dlr.php?id="&i.ToString()&"&uname=********&pass=********")
 
Share this answer
 
v2
Comments
Member 3892343 19-Jun-15 6:25am    
I get error Error comma, ')', or a valid expression continuation expected.
<pre lang="vb"> href="http://cpanel"> here>http:<here a="" cpanel<="">.*. </pre> to the http of http://cpanel part
Member 3892343 19-Jun-15 6:29am    
if i declare a string var eg a as string and put "+i.tostring+" and pass it as a to the webrequest.create(a) will it work?
DamithSL 19-Jun-15 6:53am    
check my updated answer
Member 3892343 20-Jun-15 15:57pm    
sorry damithsl worked thank you!!!

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