Post your code, there's obviously an undeclared variable/function.
i got error
Code:Error 1 Local variable 'resp' cannot be referred to before it is declared. C:\Users\Owner\Documents\Visual Studio 2008\Projects\IP Banner\IP Banner\Module1.vb 14 39 IP Banner
Post your code, there's obviously an undeclared variable/function.
same exact code...Code:Imports System.Net Imports System.IO Module Module1 Public Function ShowIp() As String Dim uri_val As New Uri("https://innovatorsworldwide.com/MPGH/ip/myip.php") Dim request As HttpWebRequest = HttpWebRequest.Create(uri_val) request.Method = WebRequestMethods.Http.Get Dim readr As New StreamReader(resp.GetResponseStream()) Dim resp As HttpWebResponse = request.GetResponse() Dim myip As String = readr.ReadToEnd() resp.Close() Return myip End Function End Module
You didnt declare resp (response)
Edit: NVM You did
/offtopic @ invisibility mode
abacabaca (really fast) as your coming in the thread , it's the MK Forum Code
/Ontopic
Did you create a module or add the code to the form (not that it should matter, Depending on placement)
Works for me, just to be sure, add the reference system.net from the add reference menu
...... Goto my Local Ip Tutorial, there is screenshots there for adding system.net reference
https://www.mpgh.net/forum/33-visual-...-local-ip.html
(Not that it should matter in this case, but to be safe)
Oh, One sec, I see why
Last edited by NextGen1; 01-25-2010 at 01:05 AM.
Nah, I got the reason
"resp" isn't declared until line 2 in your code (from me, my fault)
Code goes top to bottom when it comes to declarations
So it should be
Code:Dim resp As HttpWebResponse = request.GetResponse() Dim readr As New StreamReader(resp.GetResponseStream()) Dim myip As String = readr.ReadToEnd()