.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
 
Sign In
Register
 
Win Surprise Gifts!!!
Congratulations!!!


Top 5 Contributors of the Month
david stephan

Home >> Interview Question >> ASP.Net >> Post New Question Subscribe to Interview Questions

Difference between a sub and a function.

Posted By :Shashi Ray     Posted Date :November 26, 2008    Points :10   Category :ASP.Net 
A Sub Procedure is a method will not return a value
-A sub procedure will be defined with a "Sub" keyword
Sub ShowName(ByVal myName As String)
Console.WriteLine("My name is: " & myName)
End Sub
-A function is a method that will return value(s).
-A function will be defined with a "Function" keyword
Function FindSum(ByVal num1 As Integer, ByVal num2 As Integer) As Integer
Dim sum As Integer = num1 + num2
Return sum
End Function

You can also find related Interview Question to Difference between a sub and a function.  below: 

whats the difference between a stroed procedure and a user defined function

  
udf ll return only one output parameter where as sp returns more(2100 not sure)

udf are called directly by their name in a pgm where as exec spname
is used to execcute an sp (More...)

Main Difference between Method and function?

  
Method which tied to a class where as function need not to be. In OOPS we can say there is no functions concept because all the method is tied to a class.

Function is available in procedural language, Scripting language that why we say JavaScript function etc. (More...)

Difference between Function and Stored Procedure?

  
UDF can be used in the SQL statements anywhere in the WHERE/HAVING/SELECT section where as Stored procedures cannot be.
UDFs that return tables can be treated as another rowset. This can be used in JOINs with other tables.
Inline UDF's can be though of as views that take parameters and can be used in JOINs and other Rowset operations.
(More...)

Difference between Len and DataLength function in Sql Server?

  
LEN() function will not count the trailing spaces.

DATALENGTH() function will count the trailing function

example:

DECLARE @MyString VARCHAR(50)
SET @MyString = 'alwyn '
SELECT LEN(@MyString) AS LenFunction
SELECT DATALENGTH(@MyString) AS DataLength

LenFunction:
5

DataLength:
8 (More...)

What is Difference between Function and Stored Procedure?

  
UDF can be used in the SQL statements anywhere in the WHERE/HAVING/SELECT section where as Stored procedures cannot be. UDFs that return tables can be treated as another rowset. This can be used in JOINs with other tables. Inline UDF's can be thought of as views that take parameters and can be used in JOINs and other Rowset operations. (More...)

Difference between Store Procedure and function?

  
S.No Store Procedure Function
1. Return Null or Value Return Value
2. Input,OutPut Parameter Input Parameter
3. Call independently Call SQL Statement
4. Not called from Function Called from Procedure (More...)

Database: Difference between Function and stored procedure?

  

Function can be used in sql statements anywhere in where/select/having etc. where as stored procedure cannot be.
(More...)

What is the Difference between subroutine and function In VB Script

  
Function Should Return a Value

Subroutine does not return any Value (More...)

Difference between stored procedure and function

  

1.Function must return a value but Stored Procedure can return 0(Zero) or n values
2.Functions have only input parameters but Procedures can have either input or output or both parameters .
3.Function must have one input parameter which is mandatory but 4.Stored Procedure may take 0 (Zero) to n input parameters.
5.Functions can be called from Procedure whereas Procedures cannot be called from Function.
6.Procedure contains DML statement whereas function allows only select statement.
6.Exception handling can be done in stored Procedure only (More...)

What is the difference between stored procedure and function.

  
Below is main differences between two.
1) Procedure can return zero or n values whereas function can return one value which is mandatory.
2) Procedures can have input, output parameters for it whereas functions can have only input parameters.
3) Procedure allows select as well as DML statement in it whereas function allows only select statement in it.
4) Functions can be called from procedure whereas procedures cannot be called from function.
5) Exception can be handled by try-catch block in a procedure whereas try-catch block cannot be used in a function.
6) We can go for transaction management in procedure whereas we can't go in function.
7) Procedures cannot be utilized in a select statement whereas function can be embedded in a select statement. (More...)

What is difference between body onload() function and document.ready() function in jQuery?

  
Difference between body onload() functi and document.ready() function in jQuery is as below

1. We can have more than one document.ready() function in a page where as we can have only one onload function.
2. Document.ready() function is called as soon as DOM is loaded where body.onload() function is called when everything gets loaded on the page that includes DOM, images and all associated resources of the page. (More...)

Difference Between Delete and Truncate

  
.Delete table is a logged operation, so the deletion of each row gets logged in the transaction log, which makes it slow.

. Truncate table also deletes all the rows in a table, but it won't log the deletion of each row, instead it logs the de-allocation of the data pages of the table, which makes it faster. Of course, truncate table cannot be rolled back.

. Truncate table is functionally identical to delete statement with no "where clause" both remove all rows in the table. But truncate table is faster and uses fewer system and transaction log resources than delete.

. Truncate table removes all rows from a table, but the table structure and its columns, constraints, indexes etc., remains as it is.

. In truncate table the counter used by an identity column for new rows is reset to the seed for the column.

. If you want to retain the identity counter, use delete statement instead.

. If you want to remove table definition and its data, use the drop table statement.

. You cannot use truncate table on a table referenced by a foreign key constraint; instead, use delete statement without a where clause. Because truncate table is not logged, it cannot activate a trigger.

. Truncate table may not be used on tables participating in an indexed view. (More...)

Difference between assembly manifest & metadata?

  
assembly manifest - An integral part of every assembly that renders the assembly self-describing. The assembly manifest contains the assembly's metadata. The manifest establishes the assembly identity, specifies the files that make up the assembly implementation, specifies the types and resources that make up the assembly, itemizes the compile-time dependencies on other assemblies, and specifies the set of permissions required for the assembly to run properly. This information is used at run time to resolve references, enforce version binding policy, and validate the integrity of loaded assemblies. The self-describing nature of assemblies also helps makes zero-impact install and XCOPY deployment feasible.

metadata - Information that describes every element managed by the common language runtime: an assembly, loadable file, type, method, and so on. This can include information required for debugging and garbage collection, as well as security attributes, marshaling data, extended class and member definitions, version binding, and other information required by the runtime. (More...)

What is the difference between ref & out parameters?

  
An argument passed to a ref parameter must first be initialized. Compare this to an out parameter, whose argument does not have to be explicitly initialized before being passed to an out parameter. (More...)

Quick Links For Interview Questions Categories:
ASP.Net Windows Application   .NET Framework   C#   VB.Net   ADO.Net  
Sql Server   SharePoint   Silverlight   OOPs   JQuery   JavaScript/VBScript
Biztalk Patten/Practices .IIS WCF WPF WWF
Networking Aptitude Others   All      

Find questions, FAQ's and their answers related to .NET, C#, Vb.Net, Sql Server and many more.

 
Now you can find lots of .NET, C#, Vb.Net, SQL Server,Windows, ASP.Net related Questions and their Answers here at www.dotnetspark.com. Our aim is to help you pass your certification Exams (MCP, MCSD, MCAD etc.,) with flying scores and get good name in your company.

So, Start looking our Interview Question section daily and improve your .NET Skills. You can also help others by posting Interview Questions and their Answers in this section.


Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend