VBcoders Guest



Don't have an account yet? Register
 


Forgot Password?



Detecting if connected to LAN or WAN

by Khursheed_Siddiqui (3 Submissions)
Category: Coding Standards
Compatability: Visual Basic 5.0
Difficulty: Intermediate
Date Added: Wed 3rd February 2021
Rating: (4 Votes)

One line of code will tell you if you are connected to LAN or WAN(Internet).

Rate Detecting if connected to LAN or WAN

Private Declare Function IsNetworkAlive Lib "Sensapi.dll" (LPDFlags As Long) As Long 

Private Const NETWORK_ALIVE_LAN = &H1 'net card connection

Private Const NETWORK_ALIVE_WAN = &H2 'RAS connection

Private Const NETWORK_ALIVE_AOL = &H4 'AOL

Private Sub Form_Load()

 Dim tmp As Long

 Dim ConnectionType As String

 
 If IsNetworkAlive(tmp) = NETWORK_ALIVE_LAN Then

 ConnectionType = "LAN"

 ElseIf IsNetworkAlive(tmp) = NETWORK_ALIVE_WAN Then

 ConnectionType = "WAN"

 ElseIf IsNetworkAlive(tmp) = NETWORK_ALIVE_AOL Then

 ConnectionType = "AOL"

 Else

 ConnectionType = "Could not Determine."

 End If

 Print

 Print "Your connection type is: " & ConnectionType

 
 
End Sub

Download this snippet    Add to My Saved Code

Detecting if connected to LAN or WAN Comments

No comments have been posted about Detecting if connected to LAN or WAN. Why not be the first to post a comment about Detecting if connected to LAN or WAN.

Post your comment

Subject:
Message:
0/1000 characters