stefan1919

ByRef&ByValue Difference

Oct 8th, 2015
202
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Public Class Form1
  2.  
  3.     Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
  4.         Dim first As Double = CDbl(TextBox1.Text)
  5.         Dim second As Double = CDbl(TextBox2.Text)
  6.         SwapValues(first, second)
  7.         TextBox1.Text = CStr(first)
  8.         TextBox2.Text = CStr(second)
  9.     End Sub
  10.     Sub SwapValues(ByRef firstNumber As Double, ByRef secondNumber As Double)
  11.         Dim help As Double
  12.         help = firstNumber
  13.         firstNumber = secondNumber
  14.         secondNumber = help
  15.     End Sub
  16. End Class
Advertisement
Add Comment
Please, Sign In to add comment