Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Difference between Private Sub, Function and Class

What are the differences between the following:

  • Private Sub
  • Private Function
  • Private Class

When should each one be used?

like image 747
Furqan Sehgal Avatar asked Oct 30 '10 16:10

Furqan Sehgal


People also ask

What is the difference between a sub and a function?

A sub performs a task but does not return a value. A function returns a value of the tasks performed. Subs can be recalled from anywhere in the program and in multiple types. Functions are called by a variable.

What is Private Sub Command in VB?

What Does Private Mean? Private Sub sets the scope so that subs in outside modules cannot call that particular subroutine. This means that a sub in Module 1 could not use the Call method to initiate a Private Sub in Module 2. (

What is sub function in Visual Basic?

A Sub procedure is a series of Visual Basic statements enclosed by the Sub and End Sub statements. The Sub procedure performs a task and then returns control to the calling code, but it does not return a value to the calling code.

What is public sub in VB net?

A Sub procedure is a separate set of codes that are used in VB.NET programming to execute a specific task, and it does not return any values. The Sub procedure is enclosed by the Sub and End Sub statement.


2 Answers

Private is a modifier than gives the scope of the class, sub, or function.

A sub and a function are both subroutines, or sections of code that can be called in the program. The difference between them is that a function has a return value and a sub does not.

A class is a group of codes that can include subs, functions, and other stuff.

like image 57
xpda Avatar answered Sep 21 '22 02:09

xpda


Sub is like a function but it doesnt returns any values it just executes a proccess

like image 33
Alejandro Avatar answered Sep 24 '22 02:09

Alejandro