Discussion Locked

VB Object Names from their class

0 helpful
5 replies
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.

Hi,

I am creating a COM component for a website in VB. I have a buybasket and a sellbasket instances of a class called basket. I need to know from a basket call method which object instance is accessing it.

Is there a simple way to do this or do you need more information? my direct email is jantkea@progressivebiz.com

5 replies

by rskathait

Put a property Name in your class and then assing it your variable name as string. And use this property insedie your method to know the name of calling instance. This one is simple and easy solution. I will put better answer if I find one.

rgds,
rsKathait

by jantkea

Please give a small code example to help me understand what you mean and I will give you the points.

by rskathait

CODE FOR FORM1
--------------
Put two buttons on FORM1. One talks to buy basket and another to sell basket.

Private buy As Basket
Private sell As Basket

Private Sub Command1_Click()
buy.ShowName
End Sub

Private Sub Command2_Click()
sell.ShowName
End Sub

Private Sub Form_Load()
Set sell = New Basket
sell.Name = "sell"
Set buy = New Basket
buy.Name = "buy"
End Sub

CODE FOR CLASS BASKET
---------------------
Public Name As String

Public SubShowName()
MsgBox Name
End Sub

Rgds,
rsKathait

This discussion is closed to new replies.