473,387 Members | 1,569 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Can I pass value from VB form to VBS?

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...

Nov 21 '05 #1
3 5641

"D.P. Roberts" <dp*******@pbride.com> wrote in message
news:ud**************@tk2msftngp13.phx.gbl...
I have 3 vbscripts and a vb form with radio buttons corresponding to each
script.


Is this a VB.NET question or a "classic" VB (6 or earlier) question? Because
you have crossposted between .NET (*.dotnet.*) and non-.NET (*.vb.*) groups.
Pick one.
Nov 21 '05 #2
As I understand you are talking about WScript.
There is collection of command-line arguments in WScript object (which is
global object there and you don't need to declare it)

Then from your VB application you can call vbs like:

'this is code in VB to call vbs
Dim sComStr As String
'vbs file is just an argument of script engine (wscript.exe)
'you might need to "play" with paths to files
sComStr = "wscript.exe " & "test.vbs " & RBselection 'add argument
according to your radio-button selection
ChDir App.Path 'set current folder to that, where vbs file and
wscript.exe are located (I put them together into vb's project folder for
simplicity)
Shell sComStr 'note Shell command doesn't like paths with spaces - there
are ways around

For testing I've created the following small script (in my case it is
test.vbs)

dim varTest
If WScript.Arguments.Count then varTest=WScript.Arguments(0)
msgbox "Argument " & varTest
As a result, when I call this script with some value of RBselection, then
msgbox with this value is shown

Hope, this is what you need. If you still need to read VB's data from within
vbs, then your VB must be built as ActiveX component and then you can expose
its public interface to vbs via late binding.

Dmitriy,
MCSD.



"D.P. Roberts" <dp*******@pbride.com> wrote in message
news:ud**************@tk2msftngp13.phx.gbl...
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...

Nov 21 '05 #3
In message <ud**************@tk2msftngp13.phx.gbl>, D.P. Roberts
<dp*******@pbride.com> writes
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: ne********@NOSPAMzadsoft.com

ZAD Software Systems Web : www.zadsoft.com
Nov 21 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Nath | last post by:
Please help!? I am new to writing html, javascript, pretty new to MySQL but quite proficient at writing Perl and i'm a quick learner. I am building a database driven website and i am a little...
5
by: Seeker | last post by:
Newbie question here... I have a form with some radio buttons. To verify that at least one of the buttons was chosen I use the following code ("f" is my form object) : var btnChosen; for...
4
by: Fred | last post by:
Hi, i know how to pass a value from Javascript to ASP with a hidden field into a form and submitting it, or with cookies, but here i have to pass a lot of data in an array. There is a list of...
2
by: c676228 | last post by:
Hi, This is my first time to post asp.net question on this forum. I have a question for "How to pass the first form value to the next form" I have enrollinfo.aspx form which look like as follow:...
2
by: David Shorthouse | last post by:
Folks, I have a drop-down select menu generated server-side. I was hoping to pass more than a single variable from the option value to a javascript function. Is this possible? At the moment, my...
2
by: Karl Rhodes | last post by:
I have an application which uses mutliple forms for different tasks, all of which are mdi child forms to the applications MDI Parent form. One of these child forms (form1) will be used to select...
3
by: Brad McMillan | last post by:
Hi: I have MS C# 2005 Express Edition and I'm trying to pass a string to a new form in my project. First I created the form, Customer, with a textbox, "textBox1", and declared a string...
1
by: colleen1980 | last post by:
Hi: Can any one please tell me that how to i pass the two textbox values in the new page. If i use the form action in the popup window page then the new page is open in the same popup window as i...
5
by: JohnDriver | last post by:
Hi, I am having a form which has a text box and 3 radio buttons. I am using GET method in Ajax to pass the value. I can pass the value of the textbox fine but how to pass the value of radio...
12
by: raylopez99 | last post by:
Keywords: scope resolution, passing classes between parent and child forms, parameter constructor method, normal constructor, default constructor, forward reference, sharing classes between forms....
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.