I've converted a small VB6 program into VB.Net that reads a binary file into a custom type array but it is skipping information. Below is the file format which you can see sCode, sName and sSector all have fixed lengths.
The issue is if a value read to sCode only has 3 characters the extra 2 characters assigned to sCode are removed so the length of the variable is now 3??When I run it in VB6 the the 3 characters are read and 2 'spaces' are add to make sCode remain 5 characters in length.
How can I get VB.net to retain the fixed lengths to each variable even if the value read are not that length.?
I hope everything is clear as to what I'm after
Code:Private Structure UDTCatFormat 'UPGRADE_WARNING: Fixed-length string size must fit in the buffer. Click for more: 'ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?keyword="3C1E4426-0B80-443E-B943-0627CD55D48B"' <VBFixedString(5)> Dim sCode As String 'UPGRADE_WARNING: Fixed-length string size must fit in the buffer. Click for more: 'ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?keyword="3C1E4426-0B80-443E-B943-0627CD55D48B"' <VBFixedString(10)> Dim sName As String 'UPGRADE_WARNING: Fixed-length string size must fit in the buffer. Click for more: 'ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?keyword="3C1E4426-0B80-443E-B943-0627CD55D48B"' <VBFixedString(36)> Dim sSector As String End StructureCode:Private Sub Command1_Click(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles Command1.Click Dim tCatFormat() As UDTCatFormat ReDim tCatFormat((LOF(1) / 50) - 1) 'UPGRADE_WARNING: Get was upgraded to FileGet and has a new behavior. Click for more: 'ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?keyword="9B7D5ADD-D8FE-4819-A36C-6DEDAF088CC7"' FileGet(1, tCatFormat) FileClose(1) End Sub




When I run it in VB6 the the 3 characters are read and 2 'spaces' are add to make sCode remain 5 characters in length.
Reply With Quote