473,394 Members | 1,935 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,394 software developers and data experts.

Names of the variables as SUB arguments

I countinue to discover problems for simple tasks. Now I would like to
write code, Sub or Function, where some values (more than 1) are
calculated and are to be assigned to the variables which names I would
like to submit as arguments to this SUB /Function
How to do this.

--
Vlad. Moltchanov
Nov 12 '05 #1
7 1239
Use the ByRef option in the arguments list of the function. Perform your
calculations, set the new values, and your calling function can then use the
new values of the variables.

Mike Storr
www.veraccess.com
<vl******************@ktl.fi> wrote in message
news:40***************@ktl.fi...
I countinue to discover problems for simple tasks. Now I would like to
write code, Sub or Function, where some values (more than 1) are
calculated and are to be assigned to the variables which names I would
like to submit as arguments to this SUB /Function
How to do this.

--
Vlad. Moltchanov

Nov 12 '05 #2
vl******************@ktl.fi wrote:
I countinue to discover problems for simple tasks. Now I would like to
write code, Sub or Function, where some values (more than 1) are
calculated and are to be assigned to the variables which names I would
like to submit as arguments to this SUB /Function
How to do this.


Something looking like?

sub setValues(name1, value1, name2, value2)
(name1) = value1
(name2) = value2
end sub

?

I think that is not possible. Moreover, the variables assigned to must
be global, or at least with a scope larger than the sub itself--why use
such global variables? Can't you use a table, say Settings(settingName,
settingValue)?
--
Bas Cost Budde
http://www.heuveltop.org/BasCB
but the domain is nl

Nov 12 '05 #3
Bas Cost Budde <ba*@heuveltop.org> wrote in
news:c0***********@news2.solcon.nl:
vl******************@ktl.fi wrote:
I countinue to discover problems for simple tasks. Now I would
like to write code, Sub or Function, where some values (more than
1) are calculated and are to be assigned to the variables which
names I would like to submit as arguments to this SUB /Function
How to do this.


Something looking like?

sub setValues(name1, value1, name2, value2)
(name1) = value1
(name2) = value2
end sub

?

I think that is not possible. Moreover, the variables assigned to
must be global, or at least with a scope larger than the sub
itself--why use such global variables? Can't you use a table, say
Settings(settingName, settingValue)?


Eh?

If you pass ByRef (the default), then the values will work.

Call your sub thusly:

Dim OutsideVariable1
Dim OutsideVariable2

setValues OutsideVariable1, "foo", OutsideVariable2, "bar"

Debug.Print OutsideVariable1 & " " & OutsideVariable2

will return:

foo bar

in the debug window.

That's how you can get multiple values returned from a sub/function,
by passing variables by reference that are written to within the
sub/function.

This is a basic technique of VB.

--
David W. Fenton http://www.bway.net/~dfenton
dfenton at bway dot net http://www.bway.net/~dfassoc
Nov 12 '05 #4
David W. Fenton wrote:
Bas Cost Budde <ba*@heuveltop.org> wrote in
I think that is not possible.

Eh?


Exactly! Eh? I COMPLETELY misunderstood the question. Sorry about that,
happily I'm not the only one in the team.

--
Bas Cost Budde
http://www.heuveltop.org/BasCB
but the domain is nl

Nov 12 '05 #5
Bas Cost Budde <ba*@heuveltop.org> wrote in
news:c0**********@news2.solcon.nl:
David W. Fenton wrote:
Bas Cost Budde <ba*@heuveltop.org> wrote in

I think that is not possible.

Eh?


Exactly! Eh? I COMPLETELY misunderstood the question. Sorry about
that, happily I'm not the only one in the team.


Well, it's also possible *you* understood it and *I* didn't!

--
David W. Fenton http://www.bway.net/~dfenton
dfenton at bway dot net http://www.bway.net/~dfassoc
Nov 12 '05 #6
Thanks to all having replied.

The idea of ByRef became much more clear. However, my task was to make
an Access analog of SAS macro taking as an argument string like "name1
name2 ... name5" (number of names is not fixed) and generating
variables

name1 name2 ... name5 with, say, consequitive random numbers.

vl******************@ktl.fi wrote:

I countinue to discover problems for simple tasks. Now I would like to
write code, Sub or Function, where some values (more than 1) are
calculated and are to be assigned to the variables which names I would
like to submit as arguments to this SUB /Function
How to do this.

--
Vlad. Moltchanov


--
Vladislav Moltchanov Ph.D.

National Public Health Institute
Dept. of Epidemiology and Health Promotion
Mannerheimintie 166, 00300 Helsinki, Finland

Tel: +358 9 4744 8644
Fax: +358 9 4744 8338
Nov 12 '05 #7
On Mon, 09 Feb 2004 16:59:26 +0200, vl******************@ktl.fi wrote:
I countinue to discover problems for simple tasks. Now I would like to
write code, Sub or Function, where some values (more than 1) are
calculated and are to be assigned to the variables which names I would
like to submit as arguments to this SUB /Function
How to do this.


Are you sure what you're talking about isn't best simply handled with arrays
or collections? Parsing the names of things at run-time just to get numbered
lists is very inefficient, to the extent it's possible at all.
Nov 12 '05 #8

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

Similar topics

6
by: Mayer | last post by:
Hello: Is there a way to see at the python prompt the names of all the public methods of a class or the names exported by a module? I know that GUI-based IDEs have a nifty way of displaying...
15
by: James | last post by:
Hi, I am finding it increasingly difficult to name my variables. I am not able to think in the right way. Expert C programmers please Help. Regards,
23
by: Russ Chinoy | last post by:
Hi, This may be a totally newbie question, but I'm stumped. If I have a function such as: function DoSomething(strVarName) { ..... }
66
by: Mike Meyer | last post by:
It seems that the distinction between tuples and lists has slowly been fading away. What we call "tuple unpacking" works fine with lists on either side of the assignment, and iterators on the...
2
by: Noah | last post by:
Is there a simple way to get a dictionary of argument names and their default values for a method or function? I came up with one solution, but I feel like Python must have a simpler way. ...
20
by: Shawnk | last post by:
I would like to get the class INSTANCE name (not type name) of an 'object'. I can get the object (l_obj_ref.GetType()) and then get the (l_obj_typ.Name) for the class name. I there any way of...
55
by: Zytan | last post by:
I see that static is more restricted in C# than in C++. It appears usable only on classes and methods, and data members, but cannot be created within a method itself. Surely this is possible in...
8
by: David Veeneman | last post by:
Should a member variable be passed to a private method in the same class as a method argument, or should the method simply call the member variable? For years, I have passed member variables to...
7
by: amygdala | last post by:
Hi all, I'm starting this new project in which I'ld like to implement sort of a design pattern I have seen being used in the CodeIgniter framework. Basically, the site will examine the URI and...
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
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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:
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...
0
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...

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.