1

I'm completely new to coding, and have been trying do a lot of at home research. I'm currently using VB 2012 and have noticed that on a lot of forums people have (ByVal Sender as Object,... present when I load up a button or form, my code automatically comes up as (Sender as object.... My question is what is the difference between the two and how do they separately affect the program? Me:

Private Sub Button1_Click(sender As Object, e As EventArgs)
    'Handles Button1.Click
End Sub

Random:

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.Windows.RoutedEventArgs)
    'Handles Button1.Click
    sayHello(sender)
End Sub
jmcilhinney
  • 50,448
  • 5
  • 26
  • 46

1 Answers1

2

There is no difference. ByVal is the default mechanism for passing parameters. In older versions of VB.NET, the IDE would add ByVal by default. In newer versions, ByVal is implicit unless you specify ByRef explicitly.

jmcilhinney
  • 50,448
  • 5
  • 26
  • 46