What is the exact difference between Functions and Subs in VB.NET ?

 Posted by Akiii on 10/2/2011 | Category: VB.NET Interview questions | Views: 5212 | Points: 40

Functions return a value, and Subs don't.

Substring() is a Function, because you want some sort of answer back. You assign the answer to the Substring() function to a variable.

A Sub is some code or job that you want VB to get on with it and execute. An example is closing a form down and unloading it with Me.Close(). You don't need to return a value, here; you just want VB to close your form down.

Asked In: Many Interviews | Alert Moderator 

Comments or Responses

Login to post response