Is there any way to like 'dim obj as _______' and then control real objects with it? Like...

obj = text1
obj.text = "blah"

..and it work?

Recommended Answers

All 4 Replies

Yes. It's not generally done, and will probably make your code more difficult to follow and understand when you are trying to add/update things later..... beyond that, as was mentioned in another thread, you'll be using more memory (to create an object variable to an object that already exists) to work with data and store data that already exists in the object. HOWEVER, it CAN be done. Here is a small example that I just built, with nothing but a form and a textbox..... in the form_load, I put this:

Dim x As Object
Set x = Text1
x.Text = "hi"

And the .text property of the text1 textbox has changed to "hi". Again, I advise against this method for a large number of reasons, but certainly it can be done, and will work.

Is there a way to do like...

winsck1.senddata ("Text1")
dim x as object
winsck1.getdata RecData
set x = RecData
x.text = "hi"

because I can't seem to get it to work.

No... recdata is a variable that will contain information received from a socket. It is, in no way shape or form, an object. I don't understand what you are doing, or trying to get accomplished, but let me lay out how this reads:
1. Send The Literal String (send the word) "text1" across the network
- if you are trying to send the data that the user typed into text1
-across the network, you would do winsck1.sendata text1.text 2. declare X as an object variable
3. read data from the network, and store it in a variable called RecData
4. Try to set an object variable to the value stored in RecData
-set binds a variable to the specified object.
-you can not bind an object to a variable value....
-the RecData variable has no .text property, no enabled property
or any other kind of property.... it's just a variable that holds a
value, not an object variable.
5. Try to set the .Text Property Of the Object Variable X to "hi"
-Since You can't set X (an object variable) to a scalar variables
value, this will fail, if the line before it did not terminate the
program due to errors.

I do understand, however, what you are trying to do. You want to send an object reference across the network, and then use that object reference on the receiving machine. The problem is, the receiving machine wouldn't have that object reference.....

Well, it's kind of like a chess game. I was trying to just send the peice the other person selected and turn it into an object, but I guess I just have to keep using alot of if's, heh.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.