-
Feb 21st, 2003, 03:51 PM
#1
Thread Starter
PowerPoster
VB Snippet - Internet Status
VB Code:
Private Declare Function InternetCheckConnection Lib "wininet.dll" Alias "InternetCheckConnectionA" (ByVal lpszUrl As String, ByVal dwFlags As Long, ByVal dwReserved As Long) As Long
Private Const FLAG_ICC_FORCE_CONNECTION = &H1
Private Sub Form_Load()
If InternetCheckConnection("http://www.galahtech.com", FLAG_ICC_FORCE_CONNECTION, 0&) = 0 Then
MsgBox "No internet connection detected...", vbInformation
Else
MsgBox "Internet connection detected...", vbInformation
End If
End Sub
Remaining quiet down here !!!
BRAD HAS GIVEN ME THE ULTIMATIVE. I have chosen to stay....
-
Aug 23rd, 2003, 08:05 PM
#2
VB Code:
Private Declare Function InternetGetConnectedState Lib "wininet.dll" (ByRef lpSFlags As Long, ByVal dwReserved As Long) As Long
Private Sub Command1_Click()
If InternetGetConnectedState(0, 0) Then
MsgBox "Online"
Else
MsgBox "Offline"
End If
End Sub
Has someone helped you? Then you can Rate their helpful post.
-
Aug 23rd, 2003, 08:07 PM
#3
VB Code:
'Example by Vijay Phulwadhawa (vijaycg44@hotmail.com)
Private Declare Function InternetGetConnectedStateEx Lib "wininet.dll" (ByRef lpdwFlags As Long, ByVal lpszConnectionName As String, ByVal dwNameLen As Integer, ByVal dwReserved As Long) As Long
Dim sConnType As String * 255
Private Sub Form_Load()
Dim Ret As Long
Ret = InternetGetConnectedStateEx(Ret, sConnType, 254, 0)
If Ret = 1 Then
MsgBox "You are connected to Internet via " & sConnType, vbInformation
Else
MsgBox "You are not connected to internet", vbInformation
End If
End Sub
Has someone helped you? Then you can Rate their helpful post.
-
Aug 23rd, 2003, 08:07 PM
#4
VB Code:
Option Explicit
Private Sub Command1_Click()
Screen.MousePointer = vbHourglass
With Winsock1
.Protocol = sckTCPProtocol
.RemotePort = 80
.RemoteHost = "www.vbforums.com"
.Connect
Do While .State <> sckConnected And .State <> sckError
DoEvents
Loop
If .State = sckConnected Then
Caption = "Online"
Else
Caption = "Offline"
End If
.Close
.LocalPort = 0
End With
Screen.MousePointer = vbDefault
End Sub
Last edited by manavo11; Aug 23rd, 2003 at 09:33 PM.
Has someone helped you? Then you can Rate their helpful post.
-
Aug 20th, 2005, 03:12 PM
#5
Fanatic Member
Re: VB Snippet - Internet Status
Originally Posted by James Stanich
VB Code:
Private Declare Function InternetCheckConnection Lib "wininet.dll" Alias "InternetCheckConnectionA" (ByVal lpszUrl As String, ByVal dwFlags As Long, ByVal dwReserved As Long) As Long
Private Const FLAG_ICC_FORCE_CONNECTION = &H1
Private Sub Form_Load()
If InternetCheckConnection("http://www.galahtech.com", FLAG_ICC_FORCE_CONNECTION, 0&) = 0 Then
MsgBox "No internet connection detected...", vbInformation
Else
MsgBox "Internet connection detected...", vbInformation
End If
End Sub
Will the above code work if user is connected via LAN?
Thanx, Shiraz
-
Aug 20th, 2005, 06:01 PM
#6
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|