Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

String conversion for ActiveX method

Status
Not open for further replies.

SAPboy21

IS-IT--Management
Oct 22, 2001
1
NZ
Hi,

I have just started C++ (I'm used to programming in VB).

I'm trying to pass a string to my C++ activeX object via a method which is similar to a MAC address (made up of Hex numbers) i.e. 10:1A:26:8F:20.

I need to split this string into an array (i.e. using : as the delimeter) - I'm not too sure on what kind of type I should pass between the ActiveX (i.e. BSTR or LPCTSTR) - and how I go about splitting this (in VB there is a Split() function?!?!)

If I pass it as a string none of the functions I have found to split this string work (I cant convert from CString to a Char*)??

Any ideas??

Thanks in advance

Daniel
 
I would recommend to pass it as a BSTR and then convert it into CString. CString has also operator LPCTSTR that enables you to handle it as a "const char*".
You can also use STL stuff to parse it.
Example:
Code:
std::istringstream is( "10:1A:26:8F:20" );
std::string substr;
while ( is )
	std::getline( is, substr, ':' );
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top