Me Keyword
The me keyword refers to the current instance
of the class. This is the similar to the this keyword in c#. Now first we run
the following code without me keyword.
Module
Module1
Class hello
Private Phoneno As
Integer
Private name As
String
Public
Sub New(ByVal
phoneno As Integer,
ByVal name As
String)
phoneno = phoneno
name = name
End
Sub
Public Sub
Show()
Console.WriteLine("Your
Phoneno is :" & Phoneno.ToString())
Console.WriteLine("Your
name is : " & name)
End
Sub
End Class
Sub Main()
Dim phoneno As
Integer
Dim name As
String
Console.Write("Enter
your Phoneno : ")
phoneno =
Int32.Parse(Console.ReadLine())
Console.Write("Enter
your name : ")
name =
Console.ReadLine()
Dim obj As
New hello(phoneno,
name)
obj.Show()
Console.ReadLine()
End Sub
End
Module
Now run the application.
![con2.gif]()
Figure1.
Now run the following code with me keyword.
Module
Module1
Public Class
Demo
Private phoneno As
Integer
Private name As
String
Public Sub
New(ByVal
phoneno As Integer,
ByVal name As
String)
Me.phoneno = phoneno
Me.name = name
End Sub
Public Sub
Show()
Console.WriteLine("Your
Phoneno is :" & phoneno.ToString())
Console.WriteLine("Your
name is : " & name)
End Sub
End Class
Sub Main()
Dim phoneno As
Integer
Dim name As
String
Console.Write("Enter
your phoneno : ")
phoneno =
Int32.Parse(Console.ReadLine())
Console.Write("Enter
your name : ")
name =
Console.ReadLine()
Dim obj As
New Demo(phoneno,
name)
obj.Show()
Console.ReadLine()
End Sub
End
Module
Now run the application.
![con1.gif]()
Figure2