We Exist to Provide 100% Free Source Code and Tutorials

Custom Search


In Visual Basic, a Sub procedure is a series of statements composed by the Sub and End Sub statements. It performs a task that returns control to the calling code, but it does not return any value. it is also used to declare the name, parameter and the body of a sub procedure.


This is the syntax in declaring parameter in the parameter list:

  1. [Optional] [ByVal | ByRef] [ParamArray] parametername As datatype


You can also visit this site for the advance tutorial in declaring parameter list. Click Here


This is syntax in performing a Sub statement:

  1. [Modifiers] Sub SubName [(ParameterList)]
  3. Statements.....
  5. End Sub


  1. Public Sub cArea(ByVal len As Double, ByVal wid As Double)
  2. ' Declare a variable.
  3. Dim area As Double
  4. If len = 0 Or wid = 0 Then
  5. ' If the argument = 0 then the Sub will exit immediately.
  6. Exit Sub
  7. End If
  8. 'It calculate area of rectangle.
  9. area = len * wid
  10. ' Print the area to the message Box.
  11. MsgBox(area)
  12. End Sub
Facebook Comments
(Visited 6 times, 1 visits today)
Share this

Check Your Domain Ranking

Leave a Reply

Your email address will not be published. Required fields are marked * © 2016 Frontier Theme

Subscribe For Latest Updates

Signup for our newsletter and get notified when we publish new articles for free!

%d bloggers like this: