Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Connected to network..?

Status
Not open for further replies.

kenjoswe

Technical User
Sep 19, 2000
327
SE
Hi all,

I have an app. that is supposed to work both online and offline. When the user is online he can download prices from a server.

How can I determine if the user is online?

/Kent J.
 
It would be helpful if I knew what you mean by 'online', if you just mean logged into a network then the simplest way would be to write some code checking for the existance of a file on the file server, if the file is there you are online and if not you are not.

Create a button on a form called chek_for_online

Cut and paste the following code into the On Click procedure

Sub chek_for_online_Click()
Dim FileLen as Long, msg as Text, FileName as Text

'Assuming the file server is drive F:
FileName = "F:\somedirectory\somefilename.dat"

On Error Resume Next
Open FileName For Random As 1 Len = 1
FileLen = LOF(1)
If FileLen > 0 then
Msg = " You are online "
Close #1
Else
Msg = " Sorry! But you don't appear to be online"
Close #1 : Kill FileName
end if

Msgbox (msg)

End Sub

Hope it helps
Bruce Gregory
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top