 |
 |

11-05-2004, 04:56 PM
|
|
Freshman
|
|
Join Date: Sep 2004
Posts: 38
|
|
inet1.execute
|
Okay, How does the Inet execute code work? I mean, Ive seen it used in like 16 different ways and I cant figure out how to work it properly... none of my codes work for it. (im trying to upload to an FTP, I have set username and password and url.) I know theres about 50 threads on FTP uploading already but I just cant figure it out!
EDIT: Oops, Meant to post this in communications... I forgot what forum I was in, Sorry..
|
|

11-05-2004, 05:03 PM
|
|
Newcomer
|
|
Join Date: Nov 2004
Posts: 14
|
|
Quote:
|
Originally Posted by Jay666
Okay, How does the Inet execute code work? I mean, Ive seen it used in like 16 different ways and I cant figure out how to work it properly... none of my codes work for it. (im trying to upload to an FTP, I have set username and password and url.) I know theres about 50 threads on FTP uploading already but I just cant figure it out!
EDIT: Oops, Meant to post this in communications... I forgot what forum I was in, Sorry..
|
I know a limited amount about the Inet control, but here goes nothing.
If you're using FTP, basically it works like this:
Code:
Inet1.Execute , "lcd /directory"
The above will change the local directory to /directory. So basically you can use any commands in the Execute routine that you can in an FTP client. If you want to use the HTTP protocol, you could do something like this:
Code:
With Inet1
.URL = "http://www.google.com"
.Execute , "GET"
End With
That will get the contents of http://www.google.com and you can use the Inet1.GetChunk method to get the contents of it.
Hope this helps and I hope that I didn't mislead you with any of my help. Like I said, I know a very limited amount as I am somewhat new with VB6 (have been using it for a little under a year) so I could be wrong.
~Kevin
|
|

11-05-2004, 05:18 PM
|
|
Freshman
|
|
Join Date: Sep 2004
Posts: 38
|
|
|
Thanks, Ill make a note of that, I didnt know them.
Could anyone tell me how I would go about doing the upload using inet1.execute method? I want to upload richtextbox1's content into the file list15.txt.
Thanks.
|
|

11-05-2004, 05:29 PM
|
|
Newcomer
|
|
Join Date: Nov 2004
Posts: 14
|
|
Try something like this: (I put this together quickly...)
Code:
Dim FileNum As Integer
FileNum = FreeFile
Open Environ("TEMP") & "\list15.txt" For Output As #FileNum
Print #FileNum, RichTextBox1.Text
Close #FileNum
Inet1.Protocol = icFTP
Inet1.RemoteHost = "ftp.myserver.com" 'Change to your FTP server
Inet1.UserName = "username"
Inet1.Password = "password"
Inet1.Execute , "ascii" 'I assume you want a text file :)
Inet1.Execute , "lcd " & Environ("TEMP")
Inet1.Execute , "cd /dir/to/upload/to" 'Change this to the directory to upload to.
Inet1.Execute , "put list15.txt"
Try that. 
|
|

11-05-2004, 05:46 PM
|
|
Freshman
|
|
Join Date: Sep 2004
Posts: 38
|
|
|
I tested it and I got the error "Still executing last request" So I hit debug and it highlighted "Inet1.Execute , "put list15.txt""... Any idea how to fix it?
EDIT: I tested it again... It seems to highlight a random line of the code, not just "Inet1.Execute , "put list15.txt""...
|
|

11-05-2004, 05:56 PM
|
|
Newcomer
|
|
Join Date: Nov 2004
Posts: 14
|
|
Hm...
Try putting this after each of the Inet1.Execute statements:
Code:
While Inet1.StillExecuting
'Wait for it to stop executing
Wend
|
|

11-05-2004, 06:14 PM
|
|
Freshman
|
|
Join Date: Sep 2004
Posts: 38
|
|
|
Gah, The code makes the program stop responding... I have no idea why...
Heres the full code:
EDITED OUT CODE so the page doesnt get too long, My other post has the new code..
|
Last edited by Jay666; 11-05-2004 at 06:59 PM.
|

11-05-2004, 06:34 PM
|
|
Newcomer
|
|
Join Date: Nov 2004
Posts: 14
|
|
|
Lol, after a while of looking for a solution to this, your problem is simple:
You have the While loop after you set the password as well. It should only go after Execute commands.
|
|

11-05-2004, 06:50 PM
|
|
Freshman
|
|
Join Date: Sep 2004
Posts: 38
|
|
|
Oh yea, I read your post wrong! lol, I thought it said to put it after all the inet commands, not execute commands... thanks!
|
|

11-05-2004, 06:58 PM
|
|
Freshman
|
|
Join Date: Sep 2004
Posts: 38
|
|
Hm... It stills stops responding... ive edited the code to:
Code:
Private Sub Command2_Click()
Dim dlfile As String
Dim FileNum As Integer
'On Error GoTo Error
'Form3.Show
Form2.Command2.Enabled = False
Label1.Caption = "Connecting..."
dlfile = Inet1.OpenURL("http://**.**.**/list15.txt")
If dlfile = "" Then
MsgBox ("Error: File could not be downloaded")
Form1.Label1.Caption = Form1.Label1.Caption + vbNewLine + "[" + Time$ + "]: " + "Error: File could not be downloaded"
Else
Form3.RichTextBox1.Text = dlfile
Label1.Caption = "Adding...."
If Form3.RichTextBox1.Find("||" + Text2.Text + "||") = -1 Then
Form3.RichTextBox1.Text = Form3.RichTextBox1.Text + vbNewLine + "||" + Text2.Text + "||"
Label1.Caption = "Uploading..."
FileNum = FreeFile
Open Environ("TEMP") & "\list15.txt" For Output As #FileNum
Print #FileNum, Form3.RichTextBox1.Text
Close #FileNum
Inet1.Protocol = icFTP
Inet1.RemoteHost = "**"
Inet1.UserName = "**"
Inet1.Password = "**"
Inet1.Execute , "ascii" 'I assume you want a text file
While Inet1.StillExecuting
Wend
Inet1.Execute , "lcd " & Environ("TEMP")
While Inet1.StillExecuting
Wend
Inet1.Execute , "cd /" 'Change this to the directory to upload to.
While Inet1.StillExecuting
Wend
Inet1.Execute , "put list15.txt"
While Inet1.StillExecuting
Wend
dlfile = Inet1.OpenURL("http://**.**.**/list15.txt")
Form3.RichTextBox1.Text = dlfile
Else
MsgBox ("ERROR: Username already in list.")
End If
If Form3.RichTextBox1.Find("||" + Text2.Text + "||") >= 0 Then
Form1.Label1.Caption = Form1.Label1.Caption + vbNewLine + "[" + Time$ + "]: " + "Added " + Text2.Text
Label1.Caption = "Added " + Text2.Text
Else
Form1.Label1.Caption = Form1.Label1.Caption + vbNewLine + "[" + Time$ + "]: " + "Failed to add " + Text2.Text
Label1.Caption = "Failed to add " + Text2.Text
End If
End If
Exit Sub
Error:
Resume Next
End Sub
|
Last edited by Jay666; 11-05-2004 at 07:10 PM.
|

06-10-2009, 11:58 AM
|
|
Newcomer
|
|
Join Date: Jun 2009
Location: Michigan USA
Posts: 2
|
|
|
I know this is 5 years old now, but it might be worth adding an explanation in case anyone does a search for help with this and gets this far...! I wonder if there should be a DoEvents in the wend loop?
|
|
|
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
|
|
|
| Thread Tools |
|
|
| Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|
|
|
|
|
 |
|