hauska FTP kokeisiin tarvitttavaohjelma
text1 = Serverin osoite
text2 = Käyttäjä
text3 = Salasana
***TARVII***
Text1
-Name txtServer
Text2
-Name txtUser
Text3
-Name txtPassword
Command1
-Name cmdConnect
-Caption Connect
Command2
-Name cmdDisconnect
-Caption Disconnect
List1
-Name lstServer
Form1
Option Explicit
Private moFTP As cFTP
Private Sub Form_Load()
Set moFTP = New cFTP
EnableControls False
End Sub
Private Sub Form_Unload(Cancel As Integer)
Set moFTP = Nothing
End Sub
Private Sub cmdConnect_Click()
On Error GoTo vbErrorHandler
Dim oRS As ADOR.Recordset
Screen.MousePointer = vbHourglass
With moFTP
.Host = txtServer.Text
.User = txtUser.Text
.Password = txtPassword.Text
End With
moFTP.Connect
Set oRS = moFTP.GetDirectoryList(, "*.*")
If oRS.EOF And oRS.BOF Then
Else
oRS.MoveFirst
Do Until oRS.EOF
lstServer.AddItem oRS("name").Value
oRS.MoveNext
Loop
End If
EnableControls moFTP.Connected
Screen.MousePointer = vbDefault
Exit Sub
vbErrorHandler:
Screen.MousePointer = vbDefault
MsgBox Err.Description
End Sub
Private Sub cmdDisconnect_Click()
On Error GoTo vbErrorHandler
moFTP.Disconnect
EnableControls moFTP.Connected
lstServer.Clear
Exit Sub
vbErrorHandler:
MsgBox Err.Description
End Sub
Private Sub EnableControls(ByVal bConnected As Boolean)
txtServer.Enabled = Not (bConnected)
txtUser.Enabled = Not (bConnected)
txtPassword.Enabled = Not (bConnected)
cmdConnect.Enabled = Not (bConnected)
cmdDisconnect.Enabled = bConnected
End SubClass Module
Option Explicit
Private moFTP As cFTP
Private Sub Form_Load()
Set moFTP = New cFTP
EnableControls False
End Sub
Private Sub Form_Unload(Cancel As Integer)
Set moFTP = Nothing
End Sub
Private Sub cmdConnect_Click()
On Error GoTo vbErrorHandler
Dim oRS As ADOR.Recordset
Screen.MousePointer = vbHourglass
With moFTP
.Host = txtServer.Text
.User = txtUser.Text
.Password = txtPassword.Text
End With
moFTP.Connect
Set oRS = moFTP.GetDirectoryList(, "*.*")
If oRS.EOF And oRS.BOF Then
Else
oRS.MoveFirst
Do Until oRS.EOF
lstServer.AddItem oRS("name").Value
oRS.MoveNext
Loop
End If
EnableControls moFTP.Connected
Screen.MousePointer = vbDefault
Exit Sub
vbErrorHandler:
Screen.MousePointer = vbDefault
MsgBox Err.Description
End Sub
Private Sub cmdDisconnect_Click()
On Error GoTo vbErrorHandler
moFTP.Disconnect
EnableControls moFTP.Connected
lstServer.Clear
Exit Sub
vbErrorHandler:
MsgBox Err.Description
End Sub
Private Sub EnableControls(ByVal bConnected As Boolean)
txtServer.Enabled = Not (bConnected)
txtUser.Enabled = Not (bConnected)
txtPassword.Enabled = Not (bConnected)
cmdConnect.Enabled = Not (bConnected)
cmdDisconnect.Enabled = bConnected
End SubAihe on jo aika vanha, joten et voi enää vastata siihen.