I am trying to map a network drive, and I am trying to use the following:
VB Code:
Private Declare Function WNetAddConnection Lib "mpr.dll" Alias "WNetAddConnectionA" (ByVal lpszNetPath As String, ByVal lpszPassword As String, ByVal lpszLocalName As String) As Long Private Sub Form_Load() WNetAddConnection("\\server1\folderA", "", "G:") WNetAddConnection("\\server1\folderB", "", "H:") End Sub
I need this to be executed when the form loads, however, when I do this under the declaration
I get errors for "Declare", "Private Sub", and for "WNetAddConnection". The erros are as follows:VB Code:
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
"Declare" = Keyword is not valid as an identifier
"Private Sub" = Statement cannot appear within a method body. End of method assumed
"WNetAddConnection" = Name 'WNetAddConnection' is not declared.
I have to warn you guys, I am fairly new to VB so if I am doing something stupid, please take it easy on me. I appreciate your help.
FMNeo25




Reply With Quote