473,405 Members | 2,187 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,405 software developers and data experts.

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.Recipients.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.Recipients.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 1489
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.Recipients.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.Recipients.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.Recipients.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
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...
19
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...
10
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...
7
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...
1
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 =...
3
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...
2
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...
1
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...
0
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...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
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...
0
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...
0
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...

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.