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 16: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

891 views      
Thread locked
 

Messages in this Thread

 
96,637 Postings in 12,231 Threads, 350 registered users, 72 users online (0 registered, 72 guests)
Index | Admin contact |   Forum Time: Mar 29, 2024 - 1:28 pm UTC  |  Hits:62,407,528  (22,314 Today )
RSS Feed