rekam
Active member
Hello, I have a little problem of understanding with ByRef and ByVal. Look at this code :
[VB]
Private Sub test( )
Me.TextBox1.Text = "before"
(1) Show textBox1 content
MsgBox(Me.TextBox1.Text)
(2) Call method
Me.rere(Me.TextBox1)
(3) Show textBox1 content after the call
MsgBox(Me.TextBox1.Text)
End Sub
Private Sub rere(ByVal t As System.Windows.Forms.TextBox)
t.Text = "after"
End Sub
[/VB]
If passed with ByVal, after the call, the text should be "before" ?? Because its not the reference which is passed....
Can someone explains me whats happening ?? Thanks !
[VB]
Private Sub test( )
Me.TextBox1.Text = "before"
(1) Show textBox1 content
MsgBox(Me.TextBox1.Text)
(2) Call method
Me.rere(Me.TextBox1)
(3) Show textBox1 content after the call
MsgBox(Me.TextBox1.Text)
End Sub
Private Sub rere(ByVal t As System.Windows.Forms.TextBox)
t.Text = "after"
End Sub
[/VB]
If passed with ByVal, after the call, the text should be "before" ?? Because its not the reference which is passed....
Can someone explains me whats happening ?? Thanks !