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 bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Using VB to Open a Network Share

Status
Not open for further replies.

mannion

IS-IT--Management
Jun 24, 2002
73
GB
:-(

Hi I'm trying to use vb to open a network share. Basically A form pops up, there is a text box, you type the users name in then, click on the button below.

For the button this is the coding I have been trying to get to work!!!


Private Sub Command2_Click()

Dim Path As String
Path = "\\xx3\" + Text1.Text
Set WshNetwork = Wscript.CreateObject("Wscript.Network")
WshNetwork.MapNetworkDrive "Z:", Path

End Sub


Anyone see where I have gone wrong???? :-( :-(
 
Try this


Dim Path As String
Path = "\\\\xx3\\" & Text1.Text
Set WshNetwork = Wscript.CreateObject("Wscript.Network")
WshNetwork.MapNetworkDrive "Z:", Path




notice the double backslashes...
hope this helps

lightseeker
 
Ok Lightseeker, I have tried what you said, now instead of getting the yellow debug line on the second line I get it on the thired line of the script. Do you have any idea's???

This is line with the debug:

Set WshNetwork = Wscript.CreateObject("Wscript.Network")

Thanks for your help anyway lightseeker!! James Mannion
IT Officer
James_m_is@hotmail.com
 
Sorry, try this

Dim Path As String
Path = "\\xx3\" & Text1.Text
Set WshNetwork = Wscript.CreateObject("Wscript.Network")
WshNetwork.MapNetworkDrive "Z:", Path


leave out the double backslashes and be sure to use the ampersand

lightseeker

 
OO frustrating still coming up with the same problem cheers anyway!!! James Mannion
IT Officer
James_m_is@hotmail.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top