E5071C
This procedure is called when the user clicks the Exit button. This
procedure ends the program.
Connecting the hard disk of an external PC (Object name:
frmMapDrive)
Private Sub CommandButton1_Click()
If Not IsDriveNameInUse Then
Call MapDrive
Else
MsgBox "Drive """ & txtDrive.Text & """ is Already used", vb Critical
End If
End Sub
Private Sub CommandButton2_Click()
Call DisconnectDrive
End Sub
Private Function IsDriveNameInUse() As Boolean
Set fso = CreateObject("Scripting.FileSystemObject")
IsDriveNameInUse = fso.DriveExists(txtDrive.Text)
End Function
Private Sub MapDrive()
Set network = CreateObject("wscript.network")
Call network.MapNetworkDrive(txtDrive.Text, txtShare.Text, vbFal se, txtUser. Text, txtPasswd.Text)
End Sub
Private Sub DisconnectDrive()
Set network = CreateObject("wscript.network")
network.RemoveNetworkDrive txtDrive.Text
End Sub
Private Sub CommandButton3_Click()
Unload Me
End Sub
1440