vbscript >> Passing multiple variables to subroutine

by markleary » Wed, 20 Feb 2008 10:43:44 GMT

Hello all,

Creating a dynamic page in HTML and need to pass a few variables to a
sub. However, when I add more than one variable, I receive "Cannot
use parentheses when calling a sub".

This works:
strHTML = strHTML & _
"<input type=""radio"" name=""FF"" onClick=vbscript:dd(""var1"")>"

This does not:
strHTML = strHTML & _
"<input type=""radio"" name=""FF""

Any suggestions?

Thanks in advance to any help.

vbscript >> Passing multiple variables to subroutine

by mayayana » Wed, 20 Feb 2008 11:25:55 GMT

I find that this works:

Sub DoIt(var1, var2)
MsgBox var1 & " " & var2
End Sub

<BODY BGCOLOR="#FFFFFF" TEXT="#000000" onload="DoIt 3, 4">
<DIV align="left">


Another option would be to somehow combine the data for
two variables into one.

vbscript >> Passing multiple variables to subroutine

by Tom Lavedas » Wed, 20 Feb 2008 21:24:41 GMT

I believe the primary error in the original implementation is the
inclusion of the parentheses around subroutine arguments. However,
removing them leads to another problem because a space must be
enclosed in the final HTML literal string. This is handled using
single quotes in the HTML ...

strHTML = strHTML & _
"<input type=""radio"" name=""FF"" onClick='vbscript:dd

Personally, I tend to use the single quote to enclose literal strings
in embedded HTML wherever possible (or leave them out if there are no
embedded spaces), something like this ...

strHTML = strHTML & _
"<input type='radio' name='FF' onClick='vbscript:dd

It tends to simplify the resulting scripted literal string.

Tom Lavedas

vbscript >> Passing multiple variables to subroutine

by markleary » Thu, 21 Feb 2008 06:46:01 GMT

Awesome. Thanks to all!

Similar Threads

1. passing variables to a subroutine in VBA

2. Passing a subroutine as a parameter to another subroutine

Hi. In c/C++ i can pass the address of a subroutine to another subroutine as an actual parameter
How do I do that in VB .NET
What should be the syntax for a parameter to receive the address of a subroutine
Let's say theres a sub that creates buttons and I want it to receive as a parameter the address of the sub that handles the OnClick event for the button being created
How do I pass such a parameter

Thanks in advance


3. create an OO subroutine instead of multiple subroutines - Visual Basic/VB

4. Passing multiple objects using a Session Variable Array

I am working on several pages that are part of a registration process. On one 
page, I am allowing the user to enter multiple registrations before moving on 
to the next page. I want to capture all the registration object(s) into one 
session variable. On subsequent screens, I want to be able to access the data.

How would you set up a session variable to hold all these registration 
objects? There could be from 1 to 10 registrations (and all their ancillary 
data)  to capture. I am trying to use a temporary array to capture the data, 
then save it all to a session variable (array?) before moving on.

Or, is there a better way?


5. Passing an Updateable ADO Recordset To VBA Subroutine

6. Passing Query Parameters from form to another VBA subroutine

I've got a form that lets the user filter a table full of 
records (contacts: name, address, location, bla bla) by 
selecting from values in six different fields - and am 
using the selections from these combo boxes as the 
parameters for the underlying query.  Each time the user 
changes the variables, they can re-query and update the 
list. (that whole thing works just peachy)

Once the user has limited (filtered) the list to the 
contacts they want, I would them to be able to click a 
button and send the filtered list to Word and start a mail 

I've got some really great code (courtesy of Albert 
Kallal) that lets you set up just that - a button that 
starts a mail merge operation based on the records in the 
underlying query.

My problem is that by the time you're out there running 
all these other subroutines, the focus is away from the 
form where all of the parameters is stored, and I get 
prompted to re-enter the parameters (enter value for 
cboXYZ, and so on).

The code I'm working with passes the SQL when calling the 
function that creates the mail merge - 

Private Sub cmdMergeAll_Click()

    MergeAllWord ("select * from " & Me.RecordSource)

Is it possible to grab the selected parameters from the 
form and pass them along to the function as well?  Is 
there another way to do this?


Scott A

7. How to pass a structure to a form subroutine - VB.Net

8. pass comtrol name to a subroutine

How is it possible to pass a control name (possibly one of several) to
a subroutine in VB.Net (for aspx page)

I have multiple gridviews on a page and one of them will be exported
to Excel, however which one depends on other factors.  I have an
export routine that works but I don't want to duplicate it for each
gridview.  If I know which one gets exported I would like  to call the
sub like  ExportGV(GVName)