We help IT Professionals succeed at work.

need vb procedure/function

acdagirl
acdagirl asked
on
Medium Priority
211 Views
Last Modified: 2011-09-20
How can I write a procedure that will check whether a user is connected to/ or can access a remote file share and if not pop up an alert window?
Comment
Watch Question



I am thinking using the dir command.

untested function.


Function check_dir(str As String) As Boolean
       
    On Error GoTo er

    If Dir(str) <> "" Then
        check_dir = True
        ' no problem
    Else
        check_dir = False
        ' have access but found no dir
    End If


er:
    MsgBox "Say something here that they are not connected", vbCritical
End Function

Not the solution you were looking for? Getting a personalized solution is easy.

Ask the Experts

Author

Commented:
i can use try/catch right? I'd rather not use goto statements...
You must be using vb.net. This is for vb6 the old stuff.

But yes, you can replace the gosub with try/catch.

http://www.experts-exchange.com/Programming/Programming_Languages/Dot_Net/VB_DOT_NET/

Author

Commented:
no, I'm trying to use a macro in a word doc... so I guess try/catch doesn't work for vb6... ok. :-)
Access more of Experts Exchange with a free account
Thanks for using Experts Exchange.

Create a free account to continue.

Limited access with a free account allows you to:

  • View three pieces of content (articles, solutions, posts, and videos)
  • Ask the experts questions (counted toward content limit)
  • Customize your dashboard and profile

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.