Jump to content

C string to VB string conversion

Recommended Posts

A VB function which requires calling a string input by value:

function exec_init(ByVal FileName: String): Byte

In labview, I wired a string constant and made it a C string pointer. But it doesn't work.

I tried to understant why. By converted to a C string pointer, a null-terminator is added to the end of the labview string; but a VB string doesn't need a null-terminator and causes the misinterpretation of the original labview string. Is this correct?

If so, how can I pass a labview string to a VB program that awaits pass-by-value. Pascal string pointer is definitely not the choice, since it uses 8-bit for length info.

Link to comment

QUOTE (menghuihantang @ Feb 15 2009, 11:10 AM)

32-bit length followed by Unicode sequence, similar to Labview string.

This is not an authoritative answer -- someone else may know a better way.

One thing you could do that would work is to create a LV string where the first 4 bytes are the length of the rest of the string and then pass it to the DLL call as a C-style string pointer.

Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...

Important Information

By using this site, you agree to our Terms of Use.