I am trying to map a network drive, and I am trying to use the following:
VB Code:
  1. Private Declare Function WNetAddConnection Lib "mpr.dll" Alias "WNetAddConnectionA" (ByVal lpszNetPath As String, ByVal lpszPassword As String, ByVal lpszLocalName As String) As Long
  2.  
  3.     Private Sub Form_Load()
  4.         WNetAddConnection("\\server1\folderA", "", "G:")
  5.        WNetAddConnection("\\server1\folderB", "", "H:")
  6.     End Sub

I need this to be executed when the form loads, however, when I do this under the declaration
VB Code:
  1. Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
I get errors for "Declare", "Private Sub", and for "WNetAddConnection". The erros are as follows:
"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