Wrox Programmer Forums
|
Beginning VB 6 For coders who are new to Visual Basic, working in VB version 6 (not .NET).
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Beginning VB 6 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old March 10th, 2006, 08:32 AM
Friend of Wrox
 
Join Date: Jan 2006
Posts: 180
Thanks: 1
Thanked 1 Time in 1 Post
Send a message via ICQ to dpkbahuguna Send a message via MSN to dpkbahuguna Send a message via Yahoo to dpkbahuguna
Default Sub Parentheses

Hello there!

  I've a Question, pls answer me

when I call any Visual basic's sub(Procedure) by passing one parameter without parentheses it runs successfully but without parentheses not why is it......

And if I pass more than one parameters then it does not demand for parentheses

Thanks for any reply....

Deepak..
__________________
DPK..
 
Old March 10th, 2006, 09:34 AM
Friend of Wrox
 
Join Date: Oct 2004
Posts: 553
Thanks: 0
Thanked 1 Time in 1 Post
Send a message via MSN to vinod_yadav1919 Send a message via Yahoo to vinod_yadav1919
Default

Hi Deepak!!

Sub don't accept parentheses when we pass parameters.
Parentheses is used with function while passing parameters.

Hope this will help you


Cheers :)

vinod
 
Old March 10th, 2006, 09:38 AM
Friend of Wrox
 
Join Date: Oct 2004
Posts: 553
Thanks: 0
Thanked 1 Time in 1 Post
Send a message via MSN to vinod_yadav1919 Send a message via Yahoo to vinod_yadav1919
Default

Hii Deepak!!
 you can take a look on the same at
http://www.thescripts.com/forum/thread13279.html


Cheers :)

vinod
 
Old March 10th, 2006, 09:57 AM
Authorized User
 
Join Date: Mar 2006
Posts: 80
Thanks: 0
Thanked 0 Times in 0 Posts
Default

You may use Call Keyword.

With Call:
Call MySub (parameter1, parameter2, ..., parameterN)

without Call:

MySub parameter1, parameter2, ..., parameterN

 
Old March 11th, 2006, 12:45 AM
Friend of Wrox
 
Join Date: Jan 2006
Posts: 180
Thanks: 1
Thanked 1 Time in 1 Post
Send a message via ICQ to dpkbahuguna Send a message via MSN to dpkbahuguna Send a message via Yahoo to dpkbahuguna
Default

Quote:
quote:Originally posted by vinod_yadav1919
 Hi Deepak!!

Sub don't accept parentheses when we pass parameters.
Parentheses is used with function while passing parameters.

Hope this will help you


Cheers :)

vinod

Hi Vinod
Thanks for your reply but as you said that sub don't accept parentheses, this is not completely true because if you use the 'CALL' keyword with sub, it will take parentheses.....


Good Day

Deepak..
 
Old March 11th, 2006, 12:54 AM
Friend of Wrox
 
Join Date: Jan 2006
Posts: 180
Thanks: 1
Thanked 1 Time in 1 Post
Send a message via ICQ to dpkbahuguna Send a message via MSN to dpkbahuguna Send a message via Yahoo to dpkbahuguna
Default

Quote:
quote:Originally posted by peko
 You may use Call Keyword.

With Call:
Call MySub (parameter1, parameter2, ..., parameterN)

without Call:

MySub parameter1, parameter2, ..., parameterN


Hi Peko!
Thanks your Reply...
Can you tell me what is the difference between calling Function or Procedure with call keyword or without call keyword.

Thanks ....

Deepak..
 
Old March 11th, 2006, 06:44 AM
Authorized User
 
Join Date: Mar 2006
Posts: 80
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi!
Assumend from MSDN:

You are not required to use the Call keyword when calling a procedure. However, if you use the Call keyword to call a procedure that requires arguments, argumentlist must be enclosed in parentheses. If you omit the Call keyword, you also must omit the parentheses around argumentlist. If you use either Call syntax to call any intrinsic or user-defined function, the function's return value is discarded.

To pass a whole array to a procedure, use the array name followed by empty parentheses.

Peko

 
Old March 11th, 2006, 07:22 AM
Friend of Wrox
 
Join Date: Oct 2004
Posts: 553
Thanks: 0
Thanked 1 Time in 1 Post
Send a message via MSN to vinod_yadav1919 Send a message via Yahoo to vinod_yadav1919
Default

HI Peko!!
 That's great.


Cheers :)

vinod





Similar Threads
Thread Thread Starter Forum Replies Last Post
cannot use parentheses when calling a sub Adam H-W Classic ASP Basics 5 October 29th, 2004 03:41 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.