thanks for your help!!
much appreciated, but I was receiving inconsistent results,
probably more to do with the changes I made to the code you supplied me!

anyway I cut my losses and wrote another small C function called
format_postcode_A that calls the original function, ie

int __stdcall format_postcode_A(char * the_post_code,
char * post_code_two, char * the_post_code_three,
char * area, char * dist, char * sect, char * unit)

so that I can pass strings individually! makes more sense this way.
this now works and I am a happy chap!

thanks for the time you put in, you have increased my understanding of
VB a little bit more!!!!



"Mark Alexander Bertenshaw" <> wrote:
>"Chris" <vb.@> wrote in message news:3d51042c$1@
>> Hi all,
>> I know this is not really a win32 question, but you are the
>> group who will be most likely able to answer the question for me!!!
>> How would I declare and call the following C/c++ function ithin VB,
>> the function lives in one of my own dll's and has only needed to be called
>> from C but there is now a need for it to be called from VB.
>> int __stdcall format_postcode(char the_strings[7][20])
>> As a C/c++ programmer, and only a novice VB programmer this is something
>> that is new to me.
>> any help would be much appreciated.

>Try the following. It is not very efficient, since 2D C byte arrays are

>compatible with 1D VB string arrays. Well, that's what I assume that you
>want to do.
>Private Sub Function CopyMemory Lib "Kernel32.dll" Alias "RtlMoveMemory"

( _
> ByRef dest As Any, _
> ByRef src As Any, _
> ByVal copied As Long _
>Private Declare Function FormatPostcode Lib "<yourDLL.dll>" Alias
>"format_postcode" ( _
> ByRef the_strings As Byte _
>) As Long
>Sub Test(ByRef asStrings())
>' Actually, this could be very wrong, since I am not sure which dimension

>referenced first.
>' If it is not this way, then reverse the order of the dimensions, and all
>code that relies on it.
>' Actually ... might be more complicated .. oh well.
>Dim abytStrings(0 To 6, 0 To 19) As Byte
>Dim lIndex As Long
>Dim sTemp As String
> ' Convert the 1D VB string array into a 2D array of bytes.
> ' Note the explicit Unicode -> ANSI translation.
> For lIndex = 0 To 6
> sTemp = StrConv(asStrings(lIndex), vbFromUnicode)
> CopyMemory abytStrings(lIndex, 0), ByVal StrPtr(sTemp), LenB(sTemp)
> Next lIndex
> ' Send a pointer to the first byte of the 2D array.
> FormatPostcode abytString(0, 0)
> ' Copy byte array back into string array.
> ' Note the explicit ANSI -> Unicode translation.
> For lIndex = 0 To 6
> sTemp = Space$(10) ' Half of 20
> CopyMemory ByVal StrPtr(sTemp), abytStrings(lIndex, 0), LenB(sTemp)
> asStrings(lIndex) = StrConv(sTemp, vbUnicode)
> Next lIndex
>End Sub
>Mark Alexander Bertenshaw
>Chordiant Software, Inc.