ZmrAbdulla
Technical User
Can anyone explain please..
If I have a Class like below
When I create a new instance of the class I have to use like
What is the difference if I declare the New Instance in the Class without any "ByVal" clause?
declaring the vaiables where I instaniate a new class like
In this approach I don't have to give all the data..
Which one is correct?
I am missing something here..
Any place where I can read more on this?
________________________________________________________
Zameer Abdulla
Help to find Missing people
If I have a Class like below
Code:
Imports System.Data
Imports System.Data.OleDb
Public Class Categories
#Region "Declarations"
Private _CategoryID As Integer
Private _CategoryName As String
Private _Description As String
#End Region
#Region "Properties"
Public Property CategoryID() As Integer
Get
Return _CategoryID
End Get
Set(ByVal Value as Integer)
_CategoryID = Value
End Set
End Property
Public Property CategoryName() As String
Get
Return _CategoryName
End Get
Set(ByVal Value as String)
_CategoryName = Value
End Set
End Property
Public Property Description() As String
Get
Return _Description
End Get
Set(ByVal Value as String)
_Description = Value
End Set
End Property
#End Region
#Region "NewClass"
Public Sub New( ByVal _CategoryID As Integer, _
ByVal _CategoryName As String, _
ByVal _Description As String)
CategoryID = _CategoryID
CategoryName = _CategoryName
Description = _Description
End Sub
'...............
'...............
'...............
#End Region
End Class
When I create a new instance of the class I have to use like
Code:
Dim newcls As New Categories(1, "Cars", "Car Description")
What is the difference if I declare the New Instance in the Class without any "ByVal" clause?
Code:
Public Sub New()
CategoryID = _CategoryID
CategoryName = _CategoryName
Description = _Description
End Sub
Code:
Dim newcls As New Categories()
Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Dim CName As String = "Cars"
With newcls
.CategoryName = CName
End With
MessageBox.Show(newcls.CategoryName)
End Sub
Which one is correct?
I am missing something here..
Any place where I can read more on this?
________________________________________________________
Zameer Abdulla
Help to find Missing people