vb.net problem - ansi vs unicode

  • Thread starter Thread starter Salisha Khan
  • Start date Start date
S

Salisha Khan

I have an instance method that takes an ansi string.

Dim foo As Object

foo(String a)

The problem is Strings in VB .NET are unicode while in order for the method
to work it must accept an Ansi string. I can convert to an ansi byte array
but i can't pass a byte array, the method will only accept a string. I can't
use DllImport or Declare because the method is not static. I couldn't find
any good examples of how to use WideCharToMultibyte I'm not even sure if
this is what I need. Anybody have any ideas? Thanks

salisha
 
Salisha,
Dim foo As Object

foo(String a)

That isn't valid syntax.

The problem is Strings in VB .NET are unicode while in order for the method
to work it must accept an Ansi string. I can convert to an ansi byte array
but i can't pass a byte array, the method will only accept a string. I can't
use DllImport or Declare because the method is not static. I couldn't find
any good examples of how to use WideCharToMultibyte I'm not even sure if
this is what I need. Anybody have any ideas?


Where is this method implemented? In a COM object?



Mattias
 
I'm sorry, i had a mistake in my last post.

It should say foo.method(String a)

foo is an instance of an object from TDCIPH32Lib.dll

The .NET upgrade wizard created AxInterop.TDCIPH32Lib.dll

Interop.TDCIPH32Lib.dll.

foo.method expects an ansi string. I can only convert to an ansi byte array

which the method won't except.

i hope this makes more sense.....
 
Is the parameter a BSTR in the typelib?

Do you have any examples of how to successfully call this method from
some other language?



Mattias
 
Back
Top