Home All Groups Group Topic Archive Search About

Can I pass value from VB form to VBS?

Author
22 Mar 2005 3:43 AM
D.P. Roberts
I have 3 vbscripts and a vb form with radio buttons corresponding to each
script. The form's only purpose is to provide a nice GUI for the user to
decide which of the 3 scripts to run. Now, because the scripts are mostly
identical to one another, I'd really like to combine them into one script.
But I can't for the life of me figure out how to pass a radio button value
from a vb form to the script so the appropriate portion of the script is
executed based on which radio button was selected. Basically I need the
script to do something like this:

RBselection = <the radio button selected on the vb form>

Select Case RBselection
   Case RadioButton1
      varSelection = 1
   Case RadioButton2
      varSelection = 2
   Case RadioButton3
      varSelection = 3

If I could somehow do this, then I could use the varSelection value to run
the necessary parts of the script. Anyone know if this is possible?

Thanks in advance...

Author
7 Apr 2005 2:05 AM
Andrew D. Newbould
In message <udDaRFpLFHA.2***@tk2msftngp13.phx.gbl>, D.P. Roberts
<dprobe***@pbride.com> writes
Show quoteHide quote
>I have 3 vbscripts and a vb form with radio buttons corresponding to each
>script. The form's only purpose is to provide a nice GUI for the user to
>decide which of the 3 scripts to run. Now, because the scripts are mostly
>identical to one another, I'd really like to combine them into one script.
>But I can't for the life of me figure out how to pass a radio button value
>from a vb form to the script so the appropriate portion of the script is
>executed based on which radio button was selected. Basically I need the
>script to do something like this:
>
>RBselection = <the radio button selected on the vb form>
>
>Select Case RBselection
>   Case RadioButton1
>      varSelection = 1
>   Case RadioButton2
>      varSelection = 2
>   Case RadioButton3
>      varSelection = 3
>
>If I could somehow do this, then I could use the varSelection value to run
>the necessary parts of the script. Anyone know if this is possible?
>
>Thanks in advance...
>
>
>

Rather than Shell out to execute the vbs scripts why not add the
ScriptControl to you VB6 program.

You can then load the script into it and use the AddObject method to
pass your variables into it. The safer way would be to define a small
dummy class containing the data you wish to pass, dim a local object to
that class and then use AddObject to pass the local object.

You then only have to put your existing code into a sub or function so
you can call it from VB. Worst case you could combine all three scripts
into one using three functions and use VB to call the one required.
Easy.

--
Andrew D. Newbould                  E-Mail:  newsgroups@NOSPAMzadsoft.com

ZAD Software Systems                Web   :  www.zadsoft.com
Author
7 Apr 2005 2:05 AM
Andrew D. Newbould
In message <udDaRFpLFHA.2***@tk2msftngp13.phx.gbl>, D.P. Roberts
<dprobe***@pbride.com> writes
Show quoteHide quote
>I have 3 vbscripts and a vb form with radio buttons corresponding to each
>script. The form's only purpose is to provide a nice GUI for the user to
>decide which of the 3 scripts to run. Now, because the scripts are mostly
>identical to one another, I'd really like to combine them into one script.
>But I can't for the life of me figure out how to pass a radio button value
>from a vb form to the script so the appropriate portion of the script is
>executed based on which radio button was selected. Basically I need the
>script to do something like this:
>
>RBselection = <the radio button selected on the vb form>
>
>Select Case RBselection
>   Case RadioButton1
>      varSelection = 1
>   Case RadioButton2
>      varSelection = 2
>   Case RadioButton3
>      varSelection = 3
>
>If I could somehow do this, then I could use the varSelection value to run
>the necessary parts of the script. Anyone know if this is possible?
>
>Thanks in advance...
>
>
>

Rather than Shell out to execute the vbs scripts why not add the
ScriptControl to you VB6 program.

You can then load the script into it and use the AddObject method to
pass your variables into it. The safer way would be to define a small
dummy class containing the data you wish to pass, dim a local object to
that class and then use AddObject to pass the local object.

You then only have to put your existing code into a sub or function so
you can call it from VB. Worst case you could combine all three scripts
into one using three functions and use VB to call the one required.
Easy.

--
Andrew D. Newbould                  E-Mail:  newsgroups@NOSPAMzadsoft.com

ZAD Software Systems                Web   :  www.zadsoft.com