PDA

View Full Version : Manipilating an ASCII string in VBA



arjfca
07-11-2013, 11:38 AM
Hello

First post on the forum

A dll collection is share between Excel and Multicharts, a charting software. To exchange data between those two application, I'm using a DLL collection call Global Variable.

I got no problem to read and write numeric global variable. The problem occur when manipulating strings.

In Excel, I could read the global Variable, but If I modify it, I got erroneous result. The dll as been written in C++. I read theat C++ is using ASCII with "LSTR" format while Excel is using Unicode with "BSTR" format.

I suspect that this is the cause of the problem

Any idea on how to resolve the problem?
Martin
Public Declare Function GV_SetNamedString Lib "C:\Program Files (x86)\TS Support\MultiCharts\GlobalVariable.dll" _
(ByVal strElementLoc As String, ByVal intSetValue As String) As Long

Public Declare Function GV_GetNamedString Lib "C:\Program Files (x86)\TS Support\MultiCharts\GlobalVariable.dll" _
(ByVal strElementLoc As String, ByVal strOther As String) As String

Kenneth Hobs
07-11-2013, 11:54 AM
Welcome to the forum!

Have you tried StrConv()?


Sub ken()
Dim s As String
s = StrConv("Hello World!", vbFromUnicode)
MsgBox s
s = StrConv("Hello World!", vbUnicode)
MsgBox s
End Sub