473,782 Members | 2,525 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

DLL returns a variant data type - how to convert and use in VB .NET

I need to convert this code to VB .NET (2003).

Dim FaxMsg As IFaxMessage

Set FaxMsg = gFC.NewMessage

Dim Recip As Variant
' add a recipient to the fax recipients collection
Set Recip = FaxMsg.Recipien ts.Add(0)
Recip.Name = sWho
Recip.Company = sCompany
Recip.FaxNumber = sPhone

The problem I am having is that variant type does not exist in .NET and
FaxMsg.Recipien ts.Add(0) returns a variant type. I have Option Strict
and Option Explicit set to On. The upgrade utility converts the Variant
to type Object which is no good as I can't access Name, Company and
FaxNumber properties of Recip.

Thanks in advance

Darren Benn
MCSD

Dec 6 '06 #1
1 1507
On 6 Dec 2006 07:32:04 -0800, darrenbenn wrote:
I need to convert this code to VB .NET (2003).

Dim FaxMsg As IFaxMessage

Set FaxMsg = gFC.NewMessage

Dim Recip As Variant
' add a recipient to the fax recipients collection
Set Recip = FaxMsg.Recipien ts.Add(0)
Recip.Name = sWho
Recip.Company = sCompany
Recip.FaxNumber = sPhone

The problem I am having is that variant type does not exist in .NET and
FaxMsg.Recipien ts.Add(0) returns a variant type. I have Option Strict
and Option Explicit set to On. The upgrade utility converts the Variant
to type Object which is no good as I can't access Name, Company and
FaxNumber properties of Recip.

Thanks in advance

Darren Benn
MCSD
You can cast the object into the correct type using the CType method. So if
the type you want is a Recipient you would do it like so

dim temp as object

temp = FaxMsg.Recipien ts.Add(0)

dim Recip as Recipient = CType(temp, Recipient)

--
Bits.Bytes
http://bytes.thinkersroom.com
Dec 6 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
649
by: romi | last post by:
Hi I have a problem, I want to convert program in Visual Basic 6 to VC++6. Program in VB works OK., but in VC++ I don't know how to convert 'VARIANT' to 'Cstring'. How to convert 'VARIANT ww' to 'CString pp' In C++ debug info I have: ww={???} ww.vt=8204 pvarVal={VT_NULL}
19
2095
by: Jon Davis | last post by:
Hi guys! Just wanted to let you all know that I created a Variant structure, inspired by the old VB6 days. This is written in C#, but you can build a CLR/.NET class library assembly and reference it to your liking. ' Here is an example of use: ' start with a string of "1" Dim da As Variant = new Variant("1") ' add an integer of 2, becomes 3
10
4590
by: Lyle Fairfield | last post by:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vbaac11/html/acfctNZ_HV05186465.asp "If the value of the variant argument is Null, the Nz function returns the number zero or a zero-length string (always returns a zero-length string when used in a query expression)" **** How many records are there in FirstTable in which Product Is Null. SELECT COUNT(*) AS CountofNullProdcut
7
2149
by: Tracks | last post by:
I have old legacy code from vb5 where data was written to a file with a variant declaration (this was actually a coding error?)... in vb5 the code was: Dim thisdata as integer Dim thatdata Dim someother as integer thatdata = ubound( Array1 )
1
1515
by: darren.benn | last post by:
I need to convert this code to VB .NET (2003). Dim FaxMsg As IFaxMessage Set FaxMsg = gFC.NewMessage Dim Recip As Variant ' add a recipient to the fax recipients collection Set Recip = FaxMsg.Recipients.Add(0) Recip.Name = sWho
3
6115
by: empire5 | last post by:
I'm trying to convert a MS-Sql 6.5 VB application to SQL 2005 and vb.net. The vb app has uses a variant data type. When I try to read the variant data type from the sql 2005 database I get 8,000 characters into the variant type, however when I use the 6.5 database I get only the limited number of characters that are actually in the column.
2
2995
by: Bjoern | last post by:
Hi I have a COM object which fires an event where I have to pass an array of SHORTs as a parameter to the listening object. The array of SHORTs is encapsulated in a the CComSafeArray-class and passed as a VARIANT* in MIDL (since MIDL doesn't support SAFEARRAYs in events). In C# (.NET 1.0) the MIDL VARIANT* data-type is registered as "ref object" in the event-handler (delegate). How do I convert this "ref object" to a short array?
1
1836
by: rhyme2ri2 | last post by:
Hello all, how can i convert a variant data type into image. Actually i am retrieving an image from CCD (camera) which is in variant format. Now i want to display this image in picture/image box.(that is what i thought cud b one way ; feel free to suggest some other way of displaying my image). How can i convert this variant type to image. Any help wud b appreciated Thanks & Regards
0
2999
by: dileepsree | last post by:
My aim is :- Pass C# object as a parameter of unmanaged Dll(vc++ 6.0) method . with in the unmaaged dll methedod construct similar C++ class instance . vice versa from dll method argument VARIANT result has to be converted to C# object For this , I tried Marshal.GetNativeVariantForObject(s, p); or Marshal.StructureToPtr(segInfo, ptrValue, false);
0
10146
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10080
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9944
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8968
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5378
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5511
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4044
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3643
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2875
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.