Go Back  Xtreme Visual Basic Talk > Legacy Visual Basic (VB 4/5/6) > Communications > inet1.execute


Reply
 
Thread Tools Display Modes
  #1  
Old 11-05-2004, 04:56 PM
Jay666 Jay666 is offline
Freshman
 
Join Date: Sep 2004
Posts: 38
Default 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..
Reply With Quote
  #2  
Old 11-05-2004, 05:03 PM
kevaholic00 kevaholic00 is offline
Newcomer
 
Join Date: Nov 2004
Posts: 14
Default

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
Reply With Quote
  #3  
Old 11-05-2004, 05:18 PM
Jay666 Jay666 is offline
Freshman
 
Join Date: Sep 2004
Posts: 38
Default

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.
Reply With Quote
  #4  
Old 11-05-2004, 05:29 PM
kevaholic00 kevaholic00 is offline
Newcomer
 
Join Date: Nov 2004
Posts: 14
Default

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.
Reply With Quote
  #5  
Old 11-05-2004, 05:46 PM
Jay666 Jay666 is offline
Freshman
 
Join Date: Sep 2004
Posts: 38
Default

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""...
Reply With Quote
  #6  
Old 11-05-2004, 05:56 PM
kevaholic00 kevaholic00 is offline
Newcomer
 
Join Date: Nov 2004
Posts: 14
Default

Hm...

Try putting this after each of the Inet1.Execute statements:

Code:
While Inet1.StillExecuting
    'Wait for it to stop executing
Wend
Reply With Quote
  #7  
Old 11-05-2004, 06:14 PM
Jay666 Jay666 is offline
Freshman
 
Join Date: Sep 2004
Posts: 38
Default

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.
Reply With Quote
  #8  
Old 11-05-2004, 06:34 PM
kevaholic00 kevaholic00 is offline
Newcomer
 
Join Date: Nov 2004
Posts: 14
Default

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.
Reply With Quote
  #9  
Old 11-05-2004, 06:50 PM
Jay666 Jay666 is offline
Freshman
 
Join Date: Sep 2004
Posts: 38
Default

Oh yea, I read your post wrong! lol, I thought it said to put it after all the inet commands, not execute commands... thanks!
Reply With Quote
  #10  
Old 11-05-2004, 06:58 PM
Jay666 Jay666 is offline
Freshman
 
Join Date: Sep 2004
Posts: 38
Default

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.
Reply With Quote
  #11  
Old 06-10-2009, 11:58 AM
DaveAG DaveAG is offline
Newcomer
 
Join Date: Jun 2009
Location: Michigan USA
Posts: 2
Default

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?
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Advertisement:





Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe
 
 
-->