Solved

Variant Data Type

Posted on 2004-04-05
4
244 Views
Last Modified: 2008-02-01
I have a need to dimension an array as a variant array to be accepted by an older ActiveX server application that I'm using. Since the Variant data type is no longer supported what can I pass the the server to 'trick it' into thinking it's receiving a variant array?
0
Comment
Question by:thenrich
4 Comments
 
LVL 44

Expert Comment

by:Arthur_Wood
Comment Utility
Pass it as Object.

AW
0
 
LVL 5

Author Comment

by:thenrich
Comment Utility
I tried that - no success...
0
 
LVL 7

Accepted Solution

by:
ScrptMasta earned 125 total points
Comment Utility
In Visual Basic 6.0, Variant serves as the universal data type. This means that you can store data of any type in a variable of type Variant.

In Visual Basic .NET, Object is the universal data type. A variable of type Object can hold data of any type. The Variant type is not supported, and all its functionality is supplied by Object.

Variant is still a reserved word in Visual Basic .NET, even though it has no syntactical use. This helps avoid confusion with its former meanings.

The VarType function returns a member of the VariantType enumeration that provides the data type classification of an object variable. You can also use classes in the System namespace to obtain numeric data type information for an Object instance.

Ex.

Dim SomeObj As Object
' ... ... ... ...  SomeObj is assigned some value during processing.
' ... ... ... ...  Now we want to find out the data type of SomeObj.
Dim Dtype As Integer      ' To hold numeric data type result.
Dtype = Type.GetTypeCode(SomeObj.GetType())
0
 
LVL 12

Expert Comment

by:farsight
Comment Utility
This is an excellent resource for all issues related to interop:
  http://www.dotnetinterop.com/

Microsoft realized many developers were having issues with interop, so they created this site just for related issues.

---
I think you guys are missing that thenrich is trying to pass a variant array, that is say, an array of variants.  The problem is not what single object to pass, but what parts should the object be composed of in order to marshall to a VB6 array of variants.

Is that correct, thenrich?
---
thenrich,
You may need to determine how the array of variants is represented in memory, and then to something like in this article:

"How do I call a function that returns a pointer to an array of structures?"
http://www.dotnetinterop.com/faq/?q=CalleeAllocatedStructArray
0

Featured Post

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

More often than not, we developers are confronted with a need: a need to make some kind of magic happen via code. Whether it is for a client, for the boss, or for our own personal projects, the need must be satisfied. Most of the time, the Framework…
Wouldn’t it be nice if you could test whether an element is contained in an array by using a Contains method just like the one available on List objects? Wouldn’t it be good if you could write code like this? (CODE) In .NET 3.5, this is possible…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

771 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now