1)Open up VB6, and Press Ctrl-T to open up components window.
2)Go Down to "Microsoft Internet Transfer Controls", select it, then hit Ok!
3)Make 5 Textboxes , and 2 buttons. Name the textboxes
txthost.text
txtusername.text
txtpass.text
txtremotefile.txt
txtlocalfile.txt
Then for caption for the 2 command buttons, have one Upload and the other Download..
Now you can make labels next to the textboxes, but basically its self-explanitory except for txt.host.text is where you input the URL
4) First of all we will code the download button.
I will walk you through the code
Drag the inet1 from the toolbar into you form, and change the protocol to "2 icFTP".
Code: Select all
dim HostName as string
Code: Select all
HostName = txthost.Text
Code: Select all
If LCase$(Left$(hostname, 6)) <> "ftp://" Then hostname = "ftp://" & txthost.Text
let me explain syntax here
To check out the defintions of Vb6 syntax please visit
Here
Lcase$() ---Puts everything inside the brackets into lowercase. Because textboxes are case-sensitive, we need to make it inside the case. The $ sign only means that it is a string, just to clarify and make it run faster.
Left$()---This returns a letters/words, from the left. Best way to explain this is with another example. Left$("Superman", 5). That will display 5 letters from the left. So it would return "Super"
Now that i cleared up the functions meanings I can go ahead and explain the line of code. If 6 letters from the left DO NOT equal (<>) "ftp://" then HostName = "ftp://" and the url text box.
Anyway, continuing with the code..
Code: Select all
Inet1.URL = hostname
Inet1.UserName = txtusername.Text
Inet1.Password = txtpass.Text
Here is the last line of code for download!
Code: Select all
Inet1.Execute , "Get " & txtremote.Text & " " & txtlocal.Text
Now Uploading is the exact same thing except for the last line, so I will just post the whole code for upload
Code: Select all
Dim hostname As String
hostname = txthost.Text
If LCase$(Left$(hostname, 6)) <> "FTP://" Then hostname = "ftp://" & txthost.Text
Inet1.URL = hostname
Inet1.UserName = txtusername.Text
Inet1.Password = txtpass.Text
Inet1.Execute , "Put " & txtlocal.Text & " " & txtremote.Text