Internetconnection

J

Jos Vens

Hi,

I wonder if it is possible to see if someone has connection to the internet
on startup of the application.

Now I download a small file and if it succeeds, I know the user has
connection, but it seems to be a little slow. Is there a command like:

if (InternetConnection) then
msgbox "The user is connected to the internet", vbOKOnly
else
msgbox "The user is not connected to the internet", vbOKOnly
end if

Thanks
Jos Vens
 
L

Leith Ross

Hello Jos,

Here is a macro that tests if you are connected to the internet or not.
This will work with dialup, DSL, and most LANs. If you have a LAN with
auto dial it may not work. This works with Windows 95, 98, ME, 2000. I
haven't used it on 2003. So if you are running 2003 you should test it
and see if it works correctly. Add a VBA module to your project and
copy this code into it. The function returms true if you are connected
to the internet and false uf you are not.

EXAMPLE:
Answer = IsInternetConnected


Code:
--------------------
Public Declare Function GetInternetState _
Lib "Wininet.dll" _
Alias "InternetGetConnectedState" _
(ByVal lpdwFlags As Long, _
ByVal Reserved As Long) As Long

Public Function IsInternetConnected() As Boolean

Dim Flags As Long
Dim Ret

Ret = GetInternetState(Flags, 0&)
IsInternetConnected = Ret

End Function
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top