Matt,
Thank you! This looks great. Is there a reference or module that I need to include to use the inetFTP object?
Art Frank
Manager of Information Systems
OHSU Foundation
[log in to unmask]
(503) 220-8320
>>> "Matt Hawrysko" <[log in to unmask]> 10/25/02 08:11AM >>>
Arthur,
Here is a sample of code to put, but a few quick changes will
fix that.
--------------------------- ~Code Sample` ------------------------------
Option Explicit
Private m_GettingDir As Boolean
Private flag As Boolean
Private Sub AddMessage(ByVal msg As String)
txtResults.Text = txtResults.Text & vbCrLf & msg
txtResults.SelStart = Len(txtResults.Text)
End Sub
Private Sub cmdUpload_Click()
Dim host_name As String
Dim today As Date
today = Date
Dim myFile As String
Dim i As Integer
flag = True
myFile = "MYFILE.MPEF"
' myFile = myFile & Format(today, "mmdd") & ".DATA"
' txtRemoteFile = myFile
Enabled = False
MousePointer = vbHourglass
txtResults.Text = "Working"
txtResults.SelStart = Len(txtResults.Text)
DoEvents
' You must set the URL before the user name and
' password. Otherwise the control cannot verify
' the user name and password and you get the error:
'
' Unable to connect to remote host
host_name = "XXX.XXX.XXX.XXX"
' txtHost.Text = host_name
' If LCase$(Left$(host_name, 6)) <> "" Then host_name = host_name '
"ftp://" &
inetFTP.URL = host_name
txtUserName = "USERNAME.ACCT"
txtPassword = "USERPASS,ACCTPASS"
inetFTP.UserName = txtUserName.Text
inetFTP.Password = txtPassword.Text
' Do not include the host name here. That will make
' the control try to use its default user name and
' password and you'll get the error again.
txtLocalFile = "x:\MYFILE.EXT"
' txtLocalFile = txtLocalFile & myFile
txtRemoteFile = "MYFILE.MPEF"
inetFTP.Execute , "Put " & _
txtLocalFile & " " & txtRemoteFile
m_GettingDir = True
End Sub
Private Sub Command1_Click()
End
End Sub
Private Sub Form_Load()
'Form1.Show
' Dim today As Date
' today = Date
' Dim myFile As String
' myFile = "FILENAME"
' myFile = myFile & Format(today, "mmdd") & ".DATA"
' txtRemoteFile = myFile
DoEvents
Call cmdUpload_Click
End Sub
Private Sub inetFTP_StateChanged(ByVal State As Integer)
Select Case State
Case icError
AddMessage "Error: " & _
" " & inetFTP.ResponseCode & vbCrLf & _
" " & inetFTP.ResponseInfo
Case icNone
AddMessage "None"
Case icConnecting
AddMessage "Connecting"
Case icConnected
AddMessage "Connected"
Case icDisconnecting
AddMessage "Disconnecting"
Case icDisconnected
AddMessage "Disconnected"
Case icRequestSent
AddMessage "Request Sent"
Case icRequesting
AddMessage "Requesting"
Case icReceivingResponse
AddMessage "Receiving Response"
Case icRequestSent
AddMessage "Request Sent"
Case icResponseReceived
AddMessage "Response Received"
Case icResolvingHost
AddMessage "Resolving Host"
Case icHostResolved
AddMessage "Host Resolved"
Case icResponseCompleted
AddMessage inetFTP.ResponseInfo
If m_GettingDir Then
Dim txt As String
Dim chunk As Variant
m_GettingDir = False
' Get the first chunk.
chunk = inetFTP.GetChunk(1024, icString)
DoEvents
Do While Len(chunk) > 0
txt = txt & chunk
chunk = inetFTP.GetChunk(1024, icString)
DoEvents
Loop
AddMessage "----------"
AddMessage txt
If flag = True Then
Call cmdUpload2_Click
Else
Call Command1_Click
End If
End If
Case Else
AddMessage "State = " & Format$(State)
End Select
Enabled = True
MousePointer = vbDefault
End Sub
-----Original Message-----
From: HP-3000 Systems Discussion [mailto:[log in to unmask]] On
Behalf Of Arthur Frank
Sent: Friday, October 25, 2002 10:56 AM
To: [log in to unmask]
Subject: [HP3000-L] OT: FTP using VB
Hello,
I have a whole bunch of files that I would like to FTP off of my HP 3000
using VB. In the past, I have used VB to create a .BAT file that does
the FTP for me, but that seems kludge-y at best. Does anyone know how I
would go about doing this?
TIA,
Art Frank
Manager of Information Systems
OHSU Foundation
[log in to unmask]
(503) 220-8320
* To join/leave the list, search archives, change list settings, *
* etc., please visit http://raven.utc.edu/archives/hp3000-l.html *
* To join/leave the list, search archives, change list settings, *
* etc., please visit http://raven.utc.edu/archives/hp3000-l.html *
|