473,854 Members | 1,837 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 5661

"D.P. Roberts" <dp*******@pbri de.com> wrote in message
news:ud******** ******@tk2msftn gp13.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.ex e " & "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.Argumen ts.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*******@pbri de.com> wrote in message
news:ud******** ******@tk2msftn gp13.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*******@pbri de.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********@NOSP AMzadsoft.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
6797
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 stuck: I have page of results obtained from a MySQL query presented as a table (the first column having checkboxes for each of the rows in the table, and all having the name "seqs"). I have set up a javascript (connected to a "toggle all" checkbox)...
5
3152
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 (count = 0; count <= 1; count++) { if (eval(f.RadioButtons.checked)) { btnChosen = true; }
4
5398
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 product the visitor can order by clicking one or more checkboxes. I made a form containing input with type "checkbox" like: <form> <input type="checkbox" name=ck id=ck
2
2518
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: <form id="Form1" method="post" runat="server"> <Subway:Address id="address" runat="server" Caption="Home Address"></Subway:Address> <p></p> <SUBWAY:PEOPLEINFO id="Peopleinfo" runat="server" Caption="Employee Information"></SUBWAY:PEOPLEINFO>
2
12331
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 option values consist of three numbers separated by commas. I thought I could pass these three numbers as three distinct variables to the javascript function, but it obviously doesn't work this way. e.g.
2
2333
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 a record from somewhere within a hierarchy (using a treeview and listbox to narrow down the search) and then the details from this record should be displayed on an entirely different child form (form2) by the click of a button. What I want to...
3
1807
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 "name": namespace myProject {
1
9378
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 need to open the new page in the main page window with passing the two textbox parameters into the new page. Program opens the new page but dont know how to pass the two textboxes values into the new page name deceasedToday.asp Needs help in...
5
14015
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 button? I searched a few things on Google but I find the javascript below most useful in my case but there is some problem that my code is not running: var test = document.getElementsByName("meal"); for (i = 0; i < test.length; i++) {
12
11125
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. Here is a newbie mistake that I found myself doing (as a newbie), and that even a master programmer, the guru of this forum, Jon Skeet, missed! (He knows this I'm sure, but just didn't think this was my problem; LOL, I am needling him) If...
0
11024
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10672
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10740
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10362
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9510
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7909
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5937
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4550
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
4149
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.