Can anyone explain this for me?
A sub procedure can be called with or without parentheses around the
arguments. By personal convention, I normally use parentheses. I am in
the middle of a fairly large project (for me), happily using parentheses
everywhere -- until this happened:
The following sub is defined in a class module.
Public Sub DeleteXXRecord(lngEORekNombro As Long, lngXXRekNombro As Long)
[..code..]
End Sub
In another (form) module, I call the sub thus:
Dim A As Long
Dim B As Long
A = [some long number]
B = [some long number]
DeleteXXRecord(A, B)
While typing this last line, Intellisense seems to be quite happy with what
I am typing. But as soon as I newline after entering the line, it turns
red. Doing a compile gives me "Syntax error" on this line.
I have been agonizing over what could be wrong with such a simple sub call,
trying to cut down the code to the bare basics -- all to no avail. Until
in desperation I decided to try deleting the parentheses -- thus:
DeleteXXRecord A, B
Lo and behold, this actually compiled error-free. The only sub call in the
whole project without parentheses!
I know that many people don't use use parentheses with sub calls. I do it
mainly for consistency with function calls (I've gotten into the habit).
As far as I know, parentheses around a sub's arguments should always work.
Have I got this wrong somehow???
Thanks for any help,
Lyn. 3 2537
All you need in order to keep using parens is to 'call' the sub:
Call DeleteXXRecord(A, B)
"Lyn" <l.*******@iiNet.net.auwrote in message
news:t2*****************************@40tude.net...
Can anyone explain this for me?
A sub procedure can be called with or without parentheses around the
arguments. By personal convention, I normally use parentheses. I am in
the middle of a fairly large project (for me), happily using parentheses
everywhere -- until this happened:
The following sub is defined in a class module.
Public Sub DeleteXXRecord(lngEORekNombro As Long, lngXXRekNombro As Long)
[..code..]
End Sub
In another (form) module, I call the sub thus:
Dim A As Long
Dim B As Long
A = [some long number]
B = [some long number]
DeleteXXRecord(A, B)
While typing this last line, Intellisense seems to be quite happy with
what
I am typing. But as soon as I newline after entering the line, it turns
red. Doing a compile gives me "Syntax error" on this line.
I have been agonizing over what could be wrong with such a simple sub
call,
trying to cut down the code to the bare basics -- all to no avail. Until
in desperation I decided to try deleting the parentheses -- thus:
DeleteXXRecord A, B
Lo and behold, this actually compiled error-free. The only sub call in
the
whole project without parentheses!
I know that many people don't use use parentheses with sub calls. I do it
mainly for consistency with function calls (I've gotten into the habit).
As far as I know, parentheses around a sub's arguments should always work.
Have I got this wrong somehow???
Thanks for any help,
Lyn.
In other words you can invoke a sub in two different ways
Call DeleteXXRecord(A, B)
or
DeleteXXRecord A, B
but you can't mix and match i.e.
DeleteXXRecord(A, B) or Call DeleteXXRecord A, B
--
There's ALWAYS more than one way to skin a cat!
Answers/posts based on Access 2000
Message posted via AccessMonster.com http://www.accessmonster.com/Uwe/For...ccess/200705/1
On Mon, 28 May 2007 14:34:53 GMT, missinglinq via AccessMonster.com wrote:
In other words you can invoke a sub in two different ways
Call DeleteXXRecord(A, B)
or
DeleteXXRecord A, B
but you can't mix and match i.e.
DeleteXXRecord(A, B) or Call DeleteXXRecord A, B
Thanks to both who responded. I have researched the Call statement which
confirms what you have said. I have also now tried:
Call DeleteXXRecord (A, B)
and it works as advertised.
It is strange that in three years of using the parentheses format without
the "Call" statement, it has always worked perfectly -- up until now. VBA
must be loose enough to allow this erroneous syntax in most cases.
However, the writing is on the wall -- I am going to have to change my
style of calling Subs!
Thanks for the help!
Lyn. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Will Stuyvesant |
last post by:
Hello all,
So Zope still lives, yay. Well, I like that they use Python.
<rant>
What amazed me is they write that they "added types to the variables
and hope that it will be added to the...
|
by: seberino |
last post by:
Tuples are defined with regards to parentheses ()'s as everyone knows.
This causes confusion for 1 item tuples since (5) can be interpreted
as a tuple OR as the number 5 in a mathematical...
|
by: FayeC |
last post by:
Ok....I made the appropriate additions to the spaces commented and this is
what I got now:
currentDate = new Date;
today =...
|
by: Steve |
last post by:
Hi
I have decided it is time to learn Javascript (I know PHP fairly well, so
I thought it shouldn't be too difficult!!!)
I have a couple of question though, which I can highlight with the...
|
by: zheetee |
last post by:
<script type="text/vbscript">
sub setTextBoxValue(a1,a2)
thedelete.deleteTextBox.value = a1
end sub
</script>
<td>
<a href="#"...
|
by: John Goche |
last post by:
Hello,
I would like to know why the first three statements
produce output whereas the last one does not.
Also, should parentheses be included when
constructing such an instance on the heap?...
|
by: natkw1 |
last post by:
Hi all,
I'm new to C and kind of confused on this.
I've had a look around this group for suggestions but still not sure
why the warning is occurring.
What I've done is this
<code snip>
void...
|
by: rtalbot |
last post by:
Can somebody clarify why:
Given a simple template:
template <class T> struct foo { };
This:
foo<float> bar;
|
by: vlsidesign |
last post by:
I am not sure how to think about parentheses. It seems when they are
used alongside characters it indicates a function, like addTwoNums().
But is also is used to enforce which operators and...
|
by: DolphinDB |
last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation.
Take...
|
by: DolphinDB |
last post by:
Tired of spending countless mintues downsampling your data? Look no further!
In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
|
by: ryjfgjl |
last post by:
ExcelToDatabase: batch import excel into database automatically...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: Vimpel783 |
last post by:
Hello!
Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
|
by: jfyes |
last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
|
by: ArrayDB |
last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
|
by: PapaRatzi |
last post by:
Hello,
I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
| |