ZTree.com  | ZEN  | About...  

 Index   Back

[Help!] VBS shortcut making with many arguments in a target   [Help!]

By: Martijn Coppoolse   Homepage   Voorburg, NL  
Date: Nov 29,2018 at 11:35
In Response to: [Help!] VBS shortcut making with many arguments in a target (Ryan)

> lnk.Arguments = """" & Arguments1 & """" & """" &
> Arguments2 & """" & """" & Arguments3 & """" & """" &
> Arguments4 & """"

A few points in general:

  • VB(Script) starts and ends string literals with double quotes (")
  • If you want to include double quotes in a string literal, you have to duplicate them
  • To concatenate two strings, you use the & ampersand character.
  • The above means that in general, when you see " & " in VB code, you’re concatenating two string literals, and the " & " can safely be removed. This tends to make your code more readable.
Now if you apply the last bullet hereabove to your code, you get the following (which is functionally identical to what you were using):

lnk.Arguments = """" & Arguments1 & """""" & Arguments2 & """""" & Arguments3 & """""" & Arguments4 & """"

Which immediately makes me think that's a lot of consecutive double quotes! Are you sure you shouldn't be putting spaces in between those?

Assuming the values a, b, c and d for variables Argument1 thru Argument4, lnk.Arguments will now contain:

"a""b""c""d"

So I definitely suggest putting in spaces:

lnk.Arguments = """" & Arguments1 & """ """ & Arguments2 & """ """ & Arguments3 & """ """ & Arguments4 & """"


> or
>
> lnk.Arguments = """" & Arguments1 & """"
> lnk.Arguments = """" & Arguments2 & """"
> lnk.Arguments = """" & Arguments3 & """"
> lnk.Arguments = """" & Arguments4 & """"

Here, you’re overwriting lnk.Arguments 4 times with a different string, and given the example values I used above, you’d end up with:

"d"


--
Martijn

155 views      
 

Messages in this Thread

 
94,242 Postings in 11,887 Threads, 347 registered users, 10 users online (0 registered, 10 guests)
Index | Admin contact |   Forum Time: Apr 24, 2019 - 3:49 am EDT  |  Hits:27,533,120  (483 Today )
RSS Feed