Link to home
Start Free TrialLog in
Avatar of accentin
accentin

asked on

how to create an object by getting its name from a variable?

hi
how to create an object by getting its name from a variable?
for example

dim sObjName as string
sObjName="Form1"

Now the variable sobjname has the name of the form object. How can i access and use the properties and methods of the object from this?
Avatar of NBrownoh
NBrownoh

do this instead

Dim YourVar As Object
Set YourVar = Form1

btw, you wont get the nice little dropdown menu for events and properties by declaring that in a sub.

if you would rather have that dropdown menu then do this

'In the declaration section of a form or module
Public YourVar As Form1

that will bring the dropdown menu out for that variable.
ASKER CERTIFIED SOLUTION
Avatar of Mike Tomlinson
Mike Tomlinson
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
This is a duplicate account see here https://www.experts-exchange.com/help/mistakes.jsp#4.  Please contact Community Support at https://www.experts-exchange.com/Community_Support/ to have this account closed.

If we do not do this in the next 24 hours you risk having both accounts suspended.

Thanks,
Anthony
Can we force an accept on these two questions?
I believe I answered the question correctly and should get the points.

Idle_Mind
>>I believe I answered the question correctly and should get the points.<<
I agree.  However it should be noted that the CleanupPing is just an automated script that is attempting to wake up the thread and it  does not guarantee final cleanup let alone a Moderator will be around anytime soon.  It may be months before points are awarded.  If you feel strongly about it, post a message in Community Support to get this question closed.
Moderator, my recommended disposition is:

    Accept Idle_Mind's comment(s) as an answer.

Dan Rollins -- EE database cleanup volunteer