Share
Explore BrainMass

Visual Basics 2010 Beginner

Please help design a program that demonstrate passing arguments ByVal and then ByRef. Help is needed with the coding.

It is suggested that I create a square function procedure and get an integer from the user then send it ByVal one time and get the result from the procedure and have the main program display the result. Then you can send it ByRef and have the procedure modify the original variable with the result which can be displayed.

Solution Preview

See attachments.

Module Module1

'function which calculate squre of a number passed as value
Private Function SquareByVal(ByVal num As Integer) As Integer
num = num * num
Return num
End Function

'function which calculate squre of a number passed as reference
Private Function SquareByRef(ByRef num As Integer) As Integer
num = num * num
Return num

End Function

Sub Main()

Dim displayResultByVal As Integer
Dim displayResultByRef As Integer

'ask user to enter ...

Solution Summary

The solution discusses the visual basics 2010 beginner.

$2.19