• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 255
  • Last Modified:

COM / Class in VB.net/VB 6.0

I am a very beginning programmer to learn object-oriented programming...In VB 6.0, it is called OO, and VB.net called class i guess.
First, I hope someone can send me information or project-based books so I can study that.
Second, I hope to get clear what is real different between "Get" and "Let" in CLASS.

I will use VB.net / VB 6.0 to start as my programming tools...

Thank you for all your helps.

0
riskyricky1972
Asked:
riskyricky1972
1 Solution
 
InteractiveMindCommented:
Ricky,
I don't do VB myself, but:

  > "In VB 6.0, it is called OO, and VB.net called class"

OO = Object Oriented
..VB 6.0 is not Object Oriented; (whereas VB.Net is).

"class", at least in Java, C++, etc, is basically a way of defining an object.

Perhaps I'm just totally unfamiliar with VB talk ... but from what I can see, you've got your wires crossed.

Regards;
0
 
Carl TawnSystems and Integration DeveloperCommented:
Actually, VB6 is object-oriented, but in a fairly limited fashion, its certainly not fully object oriented in the way the C++ is.
Although VB.Net is technically the next version of VB it has some pretty major differences.

Both VB6 and VB.Net have classes, and they both have the same purpose - to define a template for objects. VB6 has three types of property methods - Get, Let and Set.
Get is used to return the value of a property, Let is used to set the value of the property for an intrinsic type, Set is used to set a property that is an object.

VB.Net supports properties, but in a slighly different, and simpler, way than VB6.
0
 
tonym001Commented:
VB6
As an example

Start a new project
Add class module to it and in properties window set name to clsTest
Two choices now either:
1:  In tools in menu options select Add Procedure, set name = value, type as property and scope as public
When code is created change
Public Property Get Value() As Variant to
Public Property Get Value() As Integer
and
Public Property Let Value(ByVal vNewValue As Variant) to
Public Property Let Value(ByVal vNewValue As Integer)

2. Type the above
 Insert the following in form

Option Explicit
Dim mTest As clsTest 'declare the type you just created
Private Sub Form_Load()
Dim Count1 As Integer
Set mTest = New clsTest 'initialise the class

For Count1 = 0 To 10
    mTest.Value = Count1 'set the value
    Debug.Print mTest.Value 'get the value
End Sub
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
Arthur_WoodCommented:
In a Class, in order for a USER of that class to access the value of the property, the Property GET part is used.  This will return the value of the property.

When the USER of the class needs of assign a value to the property, the Property LET part is used, to assign the value TO the property.

As an example, let's say you have a Person Class, and that Class has a Name property.  You would then have code like this:

Public Class Person
   Private m_Name as String ' this is the CLASS variabl;e that will hold the Name VALUE

   Public Property Name() as String
       Get
           Return m_Name  ' sends back whatever happens to be the NAME of the current Person OBJECT
       End Get
       Set (byVal Value as String)
           m_Name = Value      ' saves whatever happens to be the name to be assigned to the current Person OBJECT
       End Set
   End Property
End Class


Now when you want to create a Person OBJECT ( anINSTANCE of this class), in your program:

Dim objPerson as New Person       ' create a new Person Object, using the class defined above

objPerson.Name = "Joe"    ' This object represents JOE, so we use the SET part of the Class, to assign the string "Joe" to the Name Property
.
.
.
    MessageBox.Show "The Current Person object is named " & objPerson.Name

' And here we want to retrieve the Name assigned to the Person object, so we use the GET part of the Class, to get back whatever had been stored as the Name.


This is a very simplified example, and you would probably never do anything this simple in a real program, but it was here to try to show the difference between the Get part and the Set/Let part of the Property.

AW

0
 
Arthur_WoodCommented:
just to further confuse you, VB 6 DID allow you to create your own classes, and to use them ALMOST the same as you can in VB.NET - the differences were there, but it is NOT correct to imply that VB 6 did not allow you to create your own objects.  In very technical terms, VB 6 was Object-BASED, where VB.NET is Object ORIENTED. (Believe me, to try to fully explain the meaning of those two terms as used here is a discussion that I don't think you (riskyricky1972) would want to get into.)

AW
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now