Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

pass a variable into a 'shell' command

Status
Not open for further replies.

hopelessliar

Technical User
Apr 29, 2002
89
GB
Does anyone know if it is possible to do this?

What I am actually trying to do is choose a random name from an array and then pass that name into a shell command like this:

dim Names as Variant
varData = Array("name1", "name2", "name3")


shell "net send [randomnamehere] mymessage"


If anyone has a useful hint on how to go about this, I'd be grateful.

Thanks

 
Take a look at the Randomize instruction and the Rnd function.

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Thanks for the swift reply, but it's the passing the value into the shell command that I'm most concerned about rather than the random value...
 
Look at the help for the Shell function.

Shell(pathname[,windowstyle])

[red]"... isn't sanity really just a one trick pony anyway?! I mean, all you get is one trick, rational thinking, but when you are good and crazy, oooh, oooh, oooh, the sky is the limit!" - The Tick[/red]
 
Something like this ?
shell "net send " & randomnamehere & " mymessage"


Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
What does it do?

[red]"... isn't sanity really just a one trick pony anyway?! I mean, all you get is one trick, rational thinking, but when you are good and crazy, oooh, oooh, oooh, the sky is the limit!" - The Tick[/red]
 
Ok it seems that I must have typed something wrongly, because now I have it working. For anyone who is interested, it works like this:

Dim name As String
Dim numb As Single

vardata = Array("name1", "name2", "name3", "name4")
Randomize
numb = Int((3 * Rnd) + 0)
name = vardata(numb)

Shell "net send " & name & " You will be making the tea today"

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top