Passing a String from Visual Basic 6 to an ANSI C DLLPrimary Software: Measurement Studio>>Visual Basic SupportPrimary Software Version: 1.0 Primary Software Fixed Version: N/A Secondary Software: Measurement Studio>>Visual C++ Support
Problem: Why do I get garbled ASCII characters when I try to pass a string from a Visual Basic 6 (VB 6) function to an ANSI C DLL. Solution: Visual Basic 6 (VB 6) and ANSI C store strings differently so you cannot pass a string by reference from VB 6 and to an ANSI C DLL as you would if you were to pass that string to a VB 6 function. For example: The function being called in the ANSI C DLL is declared as this: int32 __stdcall ReadString(const char tempString[])The prototype for the function call in VB 6 needs to be declared and the string passed by value instead of reference: Declare Function ReadString(ByVal physicalChannel As String) as LongThen you call the function in VB 6 with a string CreateAIVoltageChan("Hello World")Related Links: Attachments:
Report Date: 01/14/2008 Last Updated: 02/19/2008 Document ID: 4HDGQ69S |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
