For periodic determination of Ip using code. He put on a timer (interval 3 minutes). The problem is that the Window (MsgBox) crashes only 2-4 times, and then the program freezes, without error messages. Thank you in advance :

Try Dim myHttpWebRequest As HttpWebRequest = HttpWebRequest.Create("http://ip-jobs.staff-base.spb.ru/ip.cgi") Dim myHttpWebResponse As HttpWebResponse = myHttpWebRequest.GetResponse() Dim myStreamReader As New StreamReader(myHttpWebResponse.GetResponseStream, Encoding.GetEncoding(1251)) IP = myStreamReader.ReadLine.Remove(0, 8) IP = IP.Remove(IP.Length - 2, 2) MsgBox(IP) Catch e As WebException MsgBox("!!!-!!!") End Try` 

    1 answer 1

    An error seems to be in some kind of variable overflow, it seems to me that if I put the declaration of variables in a subroutine (rather in a function), then they will not be "overflowed", although I may be mistaken.