What is the difference between a Sub and a Function?

Answer Posted / mukesh

A function accepts any number of parameters (possibly
zero), does something with them, and returns a value.
A subroutine is performs an action, but doesn't return a
value.

There are two differences between a function and a
subroutine:
A)How they are invoked. B)How they are accessed.

A function call has the following syntax ::function (arg1,
arg2, ...)
where: function -->Is the name of the function. arg1,
arg2, ... Are the arguments.

A subroutine call has the following syntax ::subroutine
(arg1, arg2, ... {outputfield|'format'})
where: subroutine -->Is the name of the subroutine. arg1,
arg2, ... Are the arguments.
{outputfield|'format'} Is the name of the output field or
its format.

In addition, on some platforms, the functions are available
immediately; whereas, the subroutines are available in a
special subroutine library that you must access.

Is This Answer Correct ?    17 Yes 4 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Write the steps in Creating ActiveX Dll and Active Exe?

1704


Which type of object requires this object?

1581


Which type of object requires this object?

1499


What are 3 main differences between flexgrid control and dbgrid control?

1873


by writing MACRO CODE,i want to retrive data from one spead sheet to another UI (workbook). control will search cell by cell for each row and load the data in another workbook(UI). ex: custdetails custname lastname locaton mobile pincode custdetails raj tony hyd 555555 521245 servcreqrd srvce# srvcename location srvcepincode servcreqrd 754 drilling hyd 521784 for the above example in the another workbook retrive data like this custname Raj srvce# 754 srvcepincode 521784. while retrieving data control will search cell by cell for each row.

1684






Where can I get updated VB and other Microsoft files?

962


Which method is preferred to save data like database to the disk?

1527


How would you create Visual basic Document file?

1899


How can I change the printer Windows uses in code without using the print common dialog? How can I change orientation?

1042


Can you create a updatecascade, Deletecascade relation in Ms- Access? If no, give on eample.

1072


What is the use of OLE?

2033


What do you mean by provider?

1443


To find the current recordposition in data control.

1159


Whether HTML supports multimedia: and document links?

1424


What are the rules which should be followed while naming a variable in VB?

546