开发者

Marshalling Date type

开发者 https://www.devze.com 2022-12-21 07:31 出处:网络
I\'m trying 开发者_JS百科to marshal a VB6 structure but I don\'t know how to marshal the Date type ex:

I'm trying 开发者_JS百科to marshal a VB6 structure but I don't know how to marshal the Date type ex: DateSaved As Date

and the following array of strings: FASTNESSNAME(1 To 6) As String * 16

Thanks in advance for the help.


Dates in VB6 are very similar to dates in .NET (both are 8 bytes) so you should marshal as System.DateTime.

Fixed length strings and 1 based arrays are not supported as such in .NET. For the fixed length strings you could just use a custom .NET class?

As an addition to this you can use <VBFixedString(20)> to define a fixed string, but this doesn't work in the same way as you would expect in VB6. If you use this in a structure:

Private Structure FixedStr
    <VBFixedString(20)> Dim strTest As String
End Structure

And then use in your code - you can get differing results:

Dim fs As FixedStr
fs.strTest = "1234567890123456789012345"

MsgBox(Len(fs)) '<- Shows 20
MsgBox(Len(fs.strTest)) '<- Shows 25
0

精彩评论

暂无评论...
验证码 换一张
取 消