Jump to content
Xtreme .Net Talk

Recommended Posts

  • *Experts*
Posted
There is some VB6 code here. Not sure if it works or not since I have a DSL connection which is always on, but it can be easily be converted to VB.NET so you can try it.
Posted


Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
       'Example by Vijay Phulwadhawa (vijaycg44@hotmail.com)

       IsConnected()
       MsgBox("Is connected to the internet: " + CStr(IsConnected()))
   End Sub


   Public Function IsConnected() As Boolean
       If InternetGetConnectedState(0&, 0&) = 1 Then
           IsConnected = True
       Else
           IsConnected = False
       End If
   End Function

 

 

It always says false :(

 

 

Oh yeah and I have this where the global variables are:

 

 


Private Declare Function InternetGetConnectedState Lib "wininet.dll" (ByRef lpdwFlags As Long, ByVal dwReserved As Long) As Long

"Reality is fake, Dreams are for real"
  • Leaders
Posted

you need to change the Longs to Integers , also in a Boolean Function , use the Return method ( eg: Return True ), here's a quick example :

Private Declare Function InternetGetConnectedState Lib "wininet.dll" (ByRef lpdwFlags As Integer, ByVal dwReserved As Integer) As Integer
'/// use Integers , not Longs.
'///

   Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
       MessageBox.Show(CheckConnectionState)
   End Sub

   Private Function CheckConnectionState() As Boolean
       Dim ConnectionState As Integer = InternetGetConnectedState(vbNullString, vbNullString)
       If ConnectionState = 1 Then
           Return True
       Else
           Return False
       End If
   End Function

:)

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...