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

VBA Argument Lists

NeoPa
32,556 Expert Mod 16PB
ZeppHead80:
From syntax error, missing operator (Post #19).
but FindFirst doesn't require ( ) when passing arguments in.
Technically, there are two basic types of procedure - Sub procedure and Function procedure (although there are also Methods, but they too can be broken down in the same way into Subs and Functions). The difference being that Function procedures return values whereas Sub procedures don't. VBA is a bit of a mess with what is allowed syntactically. Due mainly to being a derivative of early BASIC PLs which were introduced to make coding possible for those without so much experience. Unlike most other language families which typically have sterner syntax requirements.

What that means for this is that VBA allows both types of procedure to be called as both types. A sub procedure should really be called similarly to a simple statement. In that version no parentheses are used and the parameters are supplied as a list after the name of the procedure call. A Function procedure, on the other hand, should be called in code that processes the return value - typically, but not limited to, assigning the value to a variable. When a function procedure is used in this way the parameters that follow the procedure call are enclosed in parentheses.

To allow function calls to avoid using or saving their returned values there is a Call statement. This really just says - Run the Function procedure but just drop the returned result. In this situation the procedure is treated as a function and the parameters are enclosed in parentheses. Sub procedures can also be used with the Call statement, and their parameters are handled the same way.

What all this boils down to is that the parentheses are not assoiciated with any particular procedure, but rather with how they are referenced in the code.
Oct 5 '11 #1
5 2532
patjones
931 Expert 512MB
NeoPa
VBA is a bit of a mess with what is allowed syntactically. Due mainly to being a derivative of early BASIC PLs which were introduced to make coding possible for those without so much experience.
A bit off topic, but since you brought it up...I've been working with VBA for about five years now and honestly don't see how it's a derivative of BASIC. As with so many people, BASIC was my first programming language. To me, they don't appear to resemble each other in any manner. What gives?
Oct 5 '11 #2
NeoPa
32,556 Expert Mod 16PB
As you say, a little off-topic (Started by my trying to explain something mentioned earlier but veering off even then). I'll create a new thread from these posts. It won't be of any great interest to anybody but leaves it public without interfering with this thread.
Oct 5 '11 #3
NeoPa
32,556 Expert Mod 16PB
ZeppHead80:
To me, they don't appear to resemble each other in any manner. What gives?
Time and evolution Pat. Just that (as far as I can see).

I'm a little surprised you don't see any similarities though. For me, as I have used some of the other languages where typeing is mandated etc, VBA seems grouped with other BASICs I've used. I never touched any form of BASIC in my professional career until the late 1980s, and I can see the similarities across the various dialects. For me, the general feel of the syntax is quite recognisable, and quite different from most other languages I've used.
Oct 5 '11 #4
patjones
931 Expert 512MB
It could be a function of me not having worked with BASIC in twenty years; my memory is certainly fragmented. The use of line numbers, GOTO, GOSUB, PRINT, and LET are all things that immediately come to mind though. I see similarities with control structures like IF...THEN...ELSE and FOR...NEXT.

I think a huge difference arose with some important modifications:
  • The deprecation of line numbers and GOTO as a means of controlling flow of execution.
  • The introduction of stronger data typing and more flexibility with variable naming.
  • The introduction of procedures and functions.
  • The introduction of objects and use of associated methods.
The list certainly isn't exhaustive. I'm sure others can contribute more. All this being said, I don't deny the connection!
Oct 5 '11 #5
NeoPa
32,556 Expert Mod 16PB
Line numbers have certainly become more optional as time has passed. There may still be some varieties that use them still though. GOTO, PRINT and LET are all still valid parts of the syntax. Labels were introduced to replace the need for line numbers some while back. LET is still an optional part of the syntax for an assignment. Try it. It still works. I'm not sure about GOSUB.

Object Oriented was always a requirement for VBA so it had to be able to handle objects. Part of why PRINT is most known as Debug.Print nowadays, but there is also the facility to Print to logical files.
  • Definitely deprecated. GoTo discouraged.
  • And the 'option' to insist on declaring all variables. That's new, and almost professional :-D
  • Technically only the separating out of the procedures. GoSub was previously used to invoke subroutine procedures. Not functions though if I remember correctly.
  • The objects and methods were a requirement from the inception (of VBA). It was almost the raison d'etre.
Oct 5 '11 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Steven D'Aprano | last post by:
I'm trying to understand the use of tuples in function argument lists. I did this: >>> def tester(a, (b,c)): .... print a, b, c .... >>> tester(1, 2) Traceback (most recent call last):...
3
by: Anders Andersen | last post by:
Hi, I have a question about about the use og va_start, va_arg, va_end, ... I'm trying to pass a variable argument list from one function to another, but I can't get it to work. My code looks...
3
by: Peteris Krumins | last post by:
Hello, Is it possible to use va lists if i prefare to define functions as following: (won't compile) void die(file, line, fn, fmt, ...) const char *file;
5
by: Jonathan Burd | last post by:
Greetings everyone, I wrote a function to learn about variable-length argument lists. I wonder if there is a better way to detect the end of the argument list than using a sentinel value like...
8
by: jamihuq | last post by:
Hello all, I just wondering if the following is supported in C: inline char* myfunc(unsigned int aLen, char *aFormat, ...) Thanks Jami
17
by: John Salerno | last post by:
A minor concern, but I'm curious if there is any kind of best practice for using whitespace within expressions and argument lists in the Python world. For example: 1 + 2 or 1+2 func(1,2)...
3
by: Tomás | last post by:
Let's say we have a variable length argument list function like so: unsigned GetAverage(unsigned a, unsigned b, ...); I wonder does the compiler go through the code looking for invocations of...
1
by: Tao | last post by:
wstring StringFormat(wstring str0, ...) { wstring result = str0; va_list list; va_start(list, str0);
5
by: kalar | last post by:
I found many pages about my problem(topic title) and i understand how it works and all the examples but after i found an example which i want to explain me look especially in function maxof and...
1
by: red floyd | last post by:
A function foo is defined as: int foo(string, ...); How to determine there are how many arguments in the list? something in the first argument has to determine this.
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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: 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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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...

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.