-
I have the following code, but am unable to figure out how to put my appropriate strings within the quotations effectively.
Code:
Private Sub cmdSend_Click()
With Inet1
.Protocol = icFTP
.URL = "xxx.xxx.xxx.xxx"
.UserName = "xxx"
.Password = "xxx"
.Execute , "PUT C:\Program Files\Test.txt Test.txt"
End With
End Sub
I want to put string variables in the place of the directory path listed. How can I do this and still get the execute command to work?
-
Use triple quotes to enclose it in quotes.
Code:
"""PUT C:\Program Files\Test.txt Test.txt"""
-
I mean I want to replace the C:\Program Files\Test.txt with something like Text1.txt, so this would require a string within the quotations it would appear, in order for the .Execute to run correctly.
-
<?>
Code:
'it's as Megatron says
Dim helpme As String
helpme = """PUT C:\Program Files\Test\Test.txt Text.txt"""
'for display
MsgBox helpme
example:
.Execute , helpme
-
Maybe it will help clarify here if I show you exactly what I want to do.
Code:
Private Sub cmdSend_Click()
Dim strFileName As String, strFileTitle As String
strFileName = "C:\Program Files\Test.txt
strFileTitle = "Test.txt"
With Inet1
.Protocol = icFTP
.URL = "xxx.xxx.xxx.xxx"
.UserName = "xxx"
.Password = "xxx"
.Execute , "PUT ""strFileName""strFileTitle"
End With
End Sub
I appreciate your helping, and hope this clarifys the conflict.
-
How about:
Code:
"PUT " & strFileName & " " & strFileTitle
-
That renders the following text line:
"PUT " C:\Test.txt Test.txt
It has to look like "PUT C:\Test.txt Test.txt" ultimately.
Thanks for helping me brainstorm this. I had thought that strings that would be inserted inside operational statements would be a cakewalk, but this one is a monster to figure out.
-
In fact to be quite honest, if I need the dir path to be separated text such as C:\Program Files\Test.txt then the operational statement must ultimately look like this...
Code:
.Execute , "PUT ""C:\Program Files\Test.txt""Test.txt"
That Operational line works like a charm every time. But I am not understanding how to do the same operational line by using string variables instead of the actual Names.
-
Try putting triple quotes around everything.
Option Explicit
Dim strOne As String
Dim strTwo As String
Dim strResult As String
Private Sub Command1_Click()
strOne = "string 1"
strTwo = "string 2"
strResult = """PUT """ & """strone""" & " " & """strtwo"""
MsgBox strResult
End Sub
strResult will contain "PUT ""strone" "strtwo"
-
Try:
have a temporary string
strTemp = "PUT " & strFileName & " " & strFileTitle
.execute , strTemp
or failing that try:
strTemp = """ & "PUT " & strFileName & " " & strFileTitle & """
It wins awards for ludicrousy but it might just work...