HELP: Cannot use parens when calling sub. 
Author Message
 HELP: Cannot use parens when calling sub.

Hi,
I'm new in Visual interdev.
This the problem i'm facing,

my code :
Recordset1.fields.setvalue ("MemberName","DAVID")

It look exactly same with the book, and it work fine with other Method,
Getvalue e.g., but for this setvalue method, I alway get the compile error
800a0414, & "Cannot use parens when calling sub."

Thank.



Mon, 05 Nov 2001 03:00:00 GMT  
 HELP: Cannot use parens when calling sub.
Hi David.

    I had this error before when using functions I've created:

FUNCTION DoSomething(x)

    DoSomething = x * 2

end FUNCTION

...

DoSomething(4)    ' This will cause the "Cannot use parens when calling sub"
error.

newvalue = DoSomething(4)  ' This works fine.

I've never tried using the setvalue method, so I'm not sure if this will
help or not...

Good Luck!

Steve


Quote:
> Hi,
> I'm new in Visual interdev.
> This the problem i'm facing,

> my code :
> Recordset1.fields.setvalue ("MemberName","DAVID")

> It look exactly same with the book, and it work fine with other Method,
> Getvalue e.g., but for this setvalue method, I alway get the compile error
> 800a0414, & "Cannot use parens when calling sub."

> Thank.



Mon, 05 Nov 2001 03:00:00 GMT  
 HELP: Cannot use parens when calling sub.
x = MyFunction(y) 'function requires paren's always
Call MySub(x) 'parens required for explicit Call
MySub y 'no parens required implicit Call
MySub(y) 'is exactly the same as above except (y) is interpreted as an
expression
MySub(x,y) 'can never work since (x,y) isn't a valid expression
MySub(x),(y) 'pass 2 args as expressions.

The confusion is because a Sub can be called explicitly with Call (parens)
or implicitly without Call (no parens) but an implicit call with a single
argument won't throw an error because it's a legal way to force the argument
to be passed ByVal to a Sub.

--
Michael Harris


Hi,
I'm new in Visual interdev.
This the problem i'm facing,

my code :
Recordset1.fields.setvalue ("MemberName","DAVID")

It look exactly same with the book, and it work fine with other Method,
Getvalue e.g., but for this setvalue method, I alway get the compile error
800a0414, & "Cannot use parens when calling sub."

Thank.



Mon, 05 Nov 2001 03:00:00 GMT  
 HELP: Cannot use parens when calling sub.
You could always just not use the parentheses - a sub generally doesn't
return a value (such as Response.Write) and if it doesn't then you should
just leave them off, ie

DoSomething x

If it does return a value that you want to use, then

y = DoSomething(x)

Quote:

>Hi David.

>    I had this error before when using functions I've created:

>FUNCTION DoSomething(x)

>    DoSomething = x * 2

>end FUNCTION

>...

>DoSomething(4)    ' This will cause the "Cannot use parens when calling
sub"
>error.

>newvalue = DoSomething(4)  ' This works fine.

>I've never tried using the setvalue method, so I'm not sure if this will
>help or not...

>Good Luck!

>Steve



>> Hi,
>> I'm new in Visual interdev.
>> This the problem i'm facing,

>> my code :
>> Recordset1.fields.setvalue ("MemberName","DAVID")

>> It look exactly same with the book, and it work fine with other Method,
>> Getvalue e.g., but for this setvalue method, I alway get the compile
error
>> 800a0414, & "Cannot use parens when calling sub."

>> Thank.



Tue, 06 Nov 2001 03:00:00 GMT  
 HELP: Cannot use parens when calling sub.
David,   I think I've figured it out.

  I've been fighting with the all day long, the
same condition, and using the same (bad) code
examples from the MS Developer's Network, and
elsewhere.

 try using this syntax...

rsTrip.fields.setValue("PeopleID"), Session
("PeopleID")

This is working for me now.   I can't believe I
wasted so much time on this.  Urghh.

- Sean

In article


Quote:
> Hi,
> I'm new in Visual interdev.
> This the problem i'm facing,

> my code :
> Recordset1.fields.setvalue

("MemberName","DAVID")
Quote:

> It look exactly same with the book, and it work

fine with other Method,
Quote:
> Getvalue e.g., but for this setvalue method, I

alway get the compile error

Quote:
> 800a0414, & "Cannot use parens when calling
sub."

> Thank.

Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.


Tue, 20 Nov 2001 03:00:00 GMT  
 HELP: Cannot use parens when calling sub.
Actually, the correct syntax is:

Recordset1.fields.setvalue "MemberName", "DAVID"
or
Call Recordset1.fields.setvalue("MemberName", "DAVID")

Putting parens around the individual arguments simply forces each to be
interpreted as an expression, effectively forcing the value to be passed by
value, even if the method you're calling expects it to be passed by
reference.

--
Michael Harris


David,   I think I've figured it out.

  I've been fighting with the all day long, the
same condition, and using the same (bad) code
examples from the MS Developer's Network, and
elsewhere.

 try using this syntax...

rsTrip.fields.setValue("PeopleID"), Session
("PeopleID")

This is working for me now.   I can't believe I
wasted so much time on this.  Urghh.

- Sean

In article


Quote:
> Hi,
> I'm new in Visual interdev.
> This the problem i'm facing,

> my code :
> Recordset1.fields.setvalue

("MemberName","DAVID")
Quote:

> It look exactly same with the book, and it work

fine with other Method,
Quote:
> Getvalue e.g., but for this setvalue method, I

alway get the compile error

Quote:
> 800a0414, & "Cannot use parens when calling
sub."

> Thank.

Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.


Tue, 20 Nov 2001 03:00:00 GMT  
 HELP: Cannot use parens when calling sub.
the idea in vb (and vbs) is this:
when you want to call a method (procedure) there are 2 ways:
1. (which you used)  methodname param1, param2 ...
2. call methodname(param1, param2 ...)

ido.

Quote:

>David,   I think I've figured it out.

>  I've been fighting with the all day long, the
>same condition, and using the same (bad) code
>examples from the MS Developer's Network, and
>elsewhere.

> try using this syntax...

>rsTrip.fields.setValue("PeopleID"), Session
>("PeopleID")

>This is working for me now.   I can't believe I
>wasted so much time on this.  Urghh.

>- Sean

>In article


>> Hi,
>> I'm new in Visual interdev.
>> This the problem i'm facing,

>> my code :
>> Recordset1.fields.setvalue
>("MemberName","DAVID")

>> It look exactly same with the book, and it work
>fine with other Method,
>> Getvalue e.g., but for this setvalue method, I
>alway get the compile error
>> 800a0414, & "Cannot use parens when calling
>sub."

>> Thank.

>Sent via Deja.com http://www.deja.com/
>Share what you know. Learn what you don't.



Wed, 28 Nov 2001 03:00:00 GMT  
 
 [ 7 post ] 

 Relevant Pages 

1. Error:Cannot use parens when call Sub HELP

2. Help with 'cannot use parens' error

3. Calling a sub or function using a variable through another sub or function

4. Cannot use parenthesis when calling a sub

5. ErrMsg: Cannot use parentheses when calling a Sub

6. Cannot use parentheses when calling a sub

7. Cannot use parentheses when calling a sub?

8. Cannot use parentheses when calling Sub

9. Cannot use parentheses when calling a Sub

10. ASP ERROR: 'Cannot use parens when calling a Sub'

11. To Microsoft: Sub cannot be called (VP6, SP5) - production customer issue

12. Help: Call a sub using a variable

 

 
Powered by phpBB® Forum Software