some basic doubts ..... i m a beginner

iinfi

New member
Joined
Jun 5, 2005
Messages
3
Location
India
Programming Experience
1-3
i created a component to validate a card number. it is a simple component which tells "A card no. has to be 16digits long for it to be a valid card number."

the code is as follows.

Public Class CardValidator
Inherits System.ComponentModel.Component

#Region " Component Designer generated code "

Public Sub New(Container As System.ComponentModel.IContainer)
MyClass.New()

'Required for Windows.Forms Class Composition Designer support
Container.Add(me)
End Sub

Public Sub New()
MyBase.New()

'This call is required by the Component Designer.
InitializeComponent()

'Add any initialization after the InitializeComponent() call

End Sub

'Component overrides dispose to clean up the component list.
Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
If disposing Then
If Not (components Is Nothing) Then
components.Dispose()
End If
End If
MyBase.Dispose(disposing)
End Sub

'Required by the Component Designer
Private components As System.ComponentModel.IContainer

'NOTE: The following procedure is required by the Component Designer
'It can be modified using the Component Designer.
'Do not modify it using the code editor.
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
components = New System.ComponentModel.Container()
End Sub

#End Region
'declaring two variables to store the name and card numbers
Private name As String
Private CardNo As String

'property declarations
Public Property CustomerName() As String
Get
Return name
End Get
Set(ByVal CustName As String)
name = CustName
End Set
End Property

Public Property CardNumber() As String
Get
Return CardNo
End Get
Set(ByVal Number As String)
CardNo = Number
End Set
End Property

Public Function validate() As Integer
Dim cardlength As Integer = 0
cardlength = CardNo.Length
Dim validLuhn As Boolean
If cardlength = 16 Then
Return True
Else
Return False
End If
End Function
End Class


plz explain what "
Public Property CustomerName() As String" stands for ...

i wud be grateful if u cud explain what the get() and set() methods do!!!

Return name .... where is the name returned ??
 
Public Property CustomerName() as String means that the component has a CustomerName property

Get means that it "gets" the customer name and returns it to whatever called it

Set means that it "sets" the cutomer name property to whatever value is passed to it

Return name means that it sends whatever value name is to whatever called for it meaning that say you have a variable declared as this object and you set it's CustomerName = "Bob" in the component it runs the Set CustomerName routine and the variable name now equals "Bob" and then when you set some other variable to CustomerName it runs through the Get CustomerName routine which simply returns the name variable's contents
 
Back
Top