Please enable JavaScript to view this site.

thinBasic Help Manual

Navigation: Introducing ThinBASIC

Example 6 - test if computer is connected to Internet

Scroll Prev Top Next More

* * HELP & MANUAL PREMIUM PACK 4 DEMO VERSION * *

This documentation was styled with a demo skin from the Premium Pack 4 add-on for Help & Manual. The contents of the skin are encrypted and not configurable. You can only publish HM projects with this skin. You cannot edit it or change it.

This version is copyright and may only be used for local testing purposes. It may not be distributed.

Please purchase the full version of the Premium Pack to get the configurable skins and remove this notice. The package will also include the Toolbox configuration utility for Premium Pack skins.

 

Test if computer is connected to Internet, in which way and report IPs.

       

Uses "inet", "ras"

 

'------------------------------------------------------------------------

' Main program - does not need to be in TBMain function, like in example 3

'------------------------------------------------------------------------

Dim Msg     As String

Dim IPCount As Long

 

If RunConnectToInternet() = True Then

   Msg = "You are connected to Internet." + $crlf + ' Notice how can you span strings across multiple lines

        "Your current connection mode is: " + INET_GetConnectionMode + $crlf

Else

   Msg = "You are NOT connected to Internet." + $crlf

End If

 

 Msg = Msg + "You have " + INET_GetIP(0) + " IPs on your box." + $crlf

 

If INET_GetIP(0) > 1 Then

   Msg += "They are:" + $crlf ' Msg += ... is equivalent of Msg = Msg + ...

Else

   Msg += "It is:" + $crlf

End If

 

For IPCount = 1 To INET_GetIP(0)

   Msg += INET_GetIP(IPCount) + $crlf

Next

 

MsgBox 0, Msg

 

'--------------------------------------------------------------------------

'Check if connection to internet is active

'If not active standard connection dialog box is started

'--------------------------------------------------------------------------

Function RunConnectToInternet() As Long

'--------------------------------------------------------------------------

 

  '--- Check current connection status

  Long IConnected = INET_GetState

 

  '---                                      

  'If already connected then use current connection

  'otherwise try to make a connection

  '---

  If not IConnected Then  

    '-If not connected, try to run AutoDialing windows functionality

    Ras_OpenDialUpDialog

 

    '-Check again connection

     IConnected = INET_GetState

 

    '-If not connect again, error message

    If not IConnected Then

      String Message = "It was not possible to connect to Internet."

      MsgBox 0, Message, %MB_OK OR %MB_ICONEXCLAMATION, "Error During Internet Connection."

    End If

  End If

 

  Return IConnected

 

End Function

 

   

 

 

Created with Help+Manual 8 and styled with Premium Pack Version 4 © by EC Software