If you’re using Visual Basic 2010 then migrate to Visual Basic 2012 when you noticed
there’s a lot of changes happening not only the colors and icons but also the
code how it will generated. In addition, the first thing that come in your mind
as you used VB 2012 and view the source code, the codes become a little compare
in previous version of Visual Basic.Net. However, the omitted keywords ByVal and System
are optional to use. Here are the example source code in VB2010 and VB2012.
This example is in VB 2010.
Private Sub btnOk_Click(ByVal
sender As System.Object,
ByVal e As
System.EventArgs) Handles
btnOk.Click
End Sub
This example is in VB 2012.
Private Sub btnOk_Click(sender As Object, e As EventArgs) Handles btnOk.Click
End Sub
Next, we are going to create Method Name in both version to see the
difference. Though, copying the code from VB 2012 to VB 2010 will automatically
generates code that compatible with VB 2010. For instance, in VB 2012 were not
using ByVal nor System keyword but when you copy
and paste it to VB 2010 the code will change automatically with ByVal and System.
VB 2010
Private Sub btnOk_Click(ByVal
sender As System.Object,
ByVal e As
System.EventArgs) Handles
btnOk.Click
MessageBox.Show(add(5,
5))
End Sub
Private Function add(ByVal x As Integer, ByVal y As Integer)
Dim a As Integer
a = x + y
Return
a
End Function
VB 2012
Private Sub btnOk_Click(sender As Object, e As EventArgs) Handles btnOk.Click
MessageBox.Show(add(5, 5))
End Sub
Private Function add(x As Integer, y As Integer)
Dim a As Integer
a = x + y
Return a
End Function
I had been created my method name
in VB 2012 without using ByVal and System keywords. Moreover, when you copy
this code and paste it in any previous version, the code will automatically add
ByVal and
System keywords.
0 comments:
Post a Comment