Hi!
I would like to know more about Visual Basic. What are the two types of procedures in this language? Can you show me how to create function using general declaration? What are the uses of Sub? Sub-name? What are arguments or parameters? How to pass arguments in sub-procedures and functions? What do you mean by return value? What is the uses of Private and Public for this? Can you show me how to implement the sub-procedures?
Thank you!
Additional information about Visual Basic 2015 and procedures
Hello Kimberly!
Here are the types of procedures in Visual Basic.
1. Sub
2. Function
Here’s how to create function in general declaration
[Private/Public] Function nameoffucntion() As DataType
<Enter and implement statements here>
nameoffunction = ReturnValue
End Function
Sub or sub-name can only return instructions or messages but not a value unlike with functions. ReturnValue instructs our program to generate and return the value out of the functions we created. Private and Public declaration in general declares the scope of the sub or function.
Here’s how to implement sub procedures.
Public Sub message1()
MsgBox “Please enter value!”, vbinformation
End Sub
Explanation:
The second line will always be generated every time we call this sub to any of our command buttons or instances. Thus, we declared this as Public so we can use it entirely to any part of our procedures.