0

How can I get an object type in a variable?

For example in VB I can declare this way:

Dim tvNode As TreeNode
tvNode = TreeView1.Nodes(1)
tvNode.Remove()

That way I can access to the functions to that object.

But in VBScript i do this:

Dim tvNode
tvNode = TreeView.Nodes(1)
tvNode.Remove() // Error. Incompatible type - tvNode is type: (name of the node) ???

How can I get a node in a variable in VBScript then?

2
  • How did you create TreeView? Where does that object come from? Commented Jul 18, 2015 at 13:29
  • It's an ActiveX element Commented Jul 20, 2015 at 9:19

2 Answers 2

0

Use TypeName to get the string representation of the type. There is also VarType which returns the VT_ENUM value of the variant type.

See also Get the type of a variable in VBScript.

Sign up to request clarification or add additional context in comments.

1 Comment

It returns type String. How can I get a TreeView Node type? So I can access to its functions such as remove, add, etc... Thanks.
0

The answer was using Set. That way I can assign objects to a variable. If I don't use Set keyword, it just assigns the string value.

2 Comments

You should have clarified that your working example was VB.NET. In all other VB languages (VB6, VBA, VBScript) Set is always required for object assignment.
I used two examples: One in VB.NET which works as I specified "That way I can access to the functions to that object". And the other example (the language I'm working with) VBScript, which I had the trouble with. Sorry If it wasn't clear.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.