I am new to vb.net in visual studio 2010. I notice in the existing project, it has a sub defined as follows:
Public Sub SelectItem(ByVal **TabPage** As TabPage)
For Each T As TabPage In TabPages
T.IsSelected = False
Next
If **TabPage** IsNot Nothing Then
For Each t As TabPage In TabPages
If m_TabsDirection = FlowDirection.LeftToRight Then t.SendToBack() Else t.BringToFront()
Next
End If
End sub
If I understand right, the TabPage surrounded by ** is a variable and the regular Tabpage is a type. But is it legal to define variable in this way? I think in c/c++, it is illegal to define something like int int.
Even if it is legal, is it common that people define variables in this way in vb.net?
Yes it’s legal and I’ve seen it on more than one occasion.
I think it’s probably more common in VB.NET than C#, since C# it would normally be
tabPagesince it’s case sensitive.As a best practice I don’t do it because it can cause confusion when reading the code. It’s easy to figure out that you’re passing around an instance of an object, but using
currentTabis also easy to understand.So, Legal: Yes
Advisable: No