|
-
Oct 16th, 2000, 11:57 AM
#1
Thread Starter
Member
I am trying to use assign a object to a object variable
I can't understand
when I should use new keyword and when I shouldn't
what is the differance 1 and 2
1 . set myobject=new myobject1
2 . set myobject=myobject1
my second question related first
I am designing a activex component that have a property
holding an object named returnobject.
mycontrol.ReturnObject = Text1
If IsObject(mycontrol.ReturnObject) Then
MsgBox "object"
Else
MsgBox "not object"
End If
msgbox displaying "not object"
why ? I sent a object to returnobject.
How can I correct it. how can I assign a value
to text1 with using my returnobject variable.
can anyone help me?
-
Oct 16th, 2000, 12:40 PM
#2
transcendental analytic
1. Instances an object of class named "myobject1"
2. Sets an object reference to "myobject1" object
I think youre a bit confuse so i'll explain:
YOu use New keyword to create a new object of a class.
New Myclass, will return an instance of Myclass
New Form1, will return a new form1.
YOU use Set keyword to assign a a object reference, for instace:
Code:
Dim a as Form1 ' Declares an object reference, no form is created yet
Dim a as New Form1 ' Declares and assign an object reference with a new form1.
Set a = New Form1 ' Creates a new instance of form1 and puts it in a.
Set b = a ' Sets the object reference of a to b, you can now acces the new form from both a and b.
SEt a = Nothing 'will clear a object reference, will also delete an object if it's the last reference.
UNload a ' will delete the object.
[/code]
Use  
writing software in C++ is like driving rivets into steel beam with a toothpick.
writing haskell makes your life easier:
reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.
-
Oct 16th, 2000, 12:48 PM
#3
transcendental analytic
Second thing, did you declare the public object variable as object/textbox or did you declare is as a variant? Because a variable is variant by default. Change it to object or textbox. It may also be the other problem, you have to use set, to assign a object reference, ifyou omit it then Let will be default, assigning the objects default property instead, that's the text in the text1 textbox. So you should use:
Code:
set mycontrol.ReturnObject = Text1
If you want to keep the variant.
Use  
writing software in C++ is like driving rivets into steel beam with a toothpick.
writing haskell makes your life easier:
reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|