We help IT Professionals succeed at work.
Get Started

How do I convert user-defined types from vb6 to .net

KarlTheHopeless
on
342 Views
Last Modified: 2012-05-09
I have a random access file which is used in VB6. The records conform to a user-defined TYPE which has a record length of 2762 bytes.

I have created a STRUCTURE in vb .net which (supposedly) contains the SAME variables - but I seem to have lost 118 bytes in the process.

Why is this so.

Here is my VB6 user-defined type ...

.....................

Type Pupildetails

fullname As String * 30: birthdate As String * 10

BEG As String * 1: COMP As String * 1: ESS As String * 1
GRAM As String * 1: READ As String * 1
SPELL As String * 1: VERB As String * 1

Temp As Integer: Eabil As Integer

TotalEngMinutes As Integer
TotalMatMinutes As Integer
NProbs As Integer

FirstEverMatPageFileno As Integer
ExtraEnglish As Integer

ClassYear As Integer: PrintMonthly As Boolean
LongshTest As Integer: PUNC As Integer

Avwords As Integer: Avsents As Integer: Home As String * 1

OpTest As Integer: PrintAnswers As Integer
HandoutTimetab As Integer
IssueNumber As Integer: TheTeacherIs As Integer
TutorNumber As Integer
HandoutFlags1 As Integer
Essential As Integer
EstimatedMabil As Integer
IndSchool As Boolean
PreviousLastMatPage As Integer: Targeting As Integer
PaceControlledBy As String * 1
DoNext As String * 2: Revising As Boolean
ExtraEssential As Integer
TotalMinsWork As Integer
AutoTimes As Integer
nstars(1 To 2) As Integer
StarsToDate As Integer

LastTestDate As Date
LastDeadLine As Date
DaysStretch As Integer
NumberToPrint As Integer: Fee As Integer
AgeLastMatPage As Integer
Deadline As Date
TestDate As Date
ExamDate As Date
ExamToCome As Boolean
EstimatedEabil As Integer
DaysLate(1 To 80) As Integer
UrgencyFactor As Single
AverageOfLastMatPages As Single
Boy As Boolean
BirthdayCardPrintedOn As Date
AvLanguage As Integer
Bulletin(1 To 304) As Byte

PluralsAge As Single: ChoosewAge As Single: spellAge As Single
PuncAge As Single: OppositesAge As Single

ProgressChartUpdated As Boolean
FirstPrintDate As Date
StoredBackUpPoint As String * 30
WhenResetMathsPages As Integer
LowestPresentNoOfResetMathsPages As Integer
PresentNoAtResetOfMathsPages As Integer
Pace As Integer
LangNormForAge As Integer: LangNormForClass As Integer
MathsNormForAge As Integer: MathsNormForClass As Integer
AveNormForAge As Integer: AveNormForClass As Integer

EarlyFinishDate(1 To 4) As Date
LateFinishDate(1 To 4) As Date
YearSixYear As Integer
DecimalAgeOfPupil As Single
DecimalAgeOfClass As Single
MatPageAverages As Single
EngPageAverages As Single
ExpectedMatAge As Single
AheadBy As Single
Asents As Single
Awords As Single
LangAheadBy As Single
grandtotalhoursdone As Single
SomeDataHasBeenWrittenToDisk As Boolean
MyAssessmentOfEabil As Integer
MyAssessmentOfMabil As Integer
ExpectedEngAge As Single
FirstEverMatPagePresentNo As Integer

TestPoint(1 To 10) As Integer
PracPoint(1 To 10) As Integer
Age(1 To 10) As Single
MinsDone(1 To 10) As Integer
PostAgeWrong As Boolean
PastStartBaseForRevision As Boolean
HighestEverMatPage As Integer
DatePrinted(1 To 200) As Date
Spare2 As String * 94

EstimatedAverageAbil As Integer
PlTest As Integer: Check12 As Integer
LastBackUpRecordNo As Integer
HalfWayImageNumber As Byte
Spare3 As Byte
NeedsExtraSpelling As Boolean
Spare4 As String * 1
Spare5(1 To 2) As Integer
AgeOfPupil As String * 6
Spare6(1 To 2) As Integer
PrintDate(1 To 2) As Date
LowestMab As Byte: HighestMab As Byte: Spare7 As Integer
LastMatPage As Integer
PuncTest As Integer: PuncPrac As Integer
ChoosewTest As Integer: ChoosewPrac As Integer
PupilHasTest As Boolean
Unsurpassability As Boolean: TestNumber As Integer

MatPagesOnlyAverage As Single: MatPagesOnlyAheadBy As Single
PuncFinished As Integer: SpellFinished As Integer: ChoosewFinished As Integer
PlFinished As Integer: OppFinished As Integer
Paid As Integer: Pupilosity As Boolean: Wonderfulness As Boolean
Magnitude As Boolean: Magnificence As Boolean
Flag(1 To 10) As Boolean
Cribs1And2 As Boolean

End Type

....................................

Here is my STRUCTURE for .NET ...

(The variables **DO** match the TYPE above).

..........................................

Structure Pupildetails

        <VBFixedString(30)> Public fullname() As String
        '
        <VBFixedString(10)> Public birthdate() As String
        <VBFixedString(1)> Public BEG() As String
        <VBFixedString(1)> Public COMP() As String
        <VBFixedString(1)> Public ESS() As String
        <VBFixedString(1)> Public GRAM() As String

        <VBFixedString(1)> Public READ() As String
        <VBFixedString(1)> Public SPELL() As String
        <VBFixedString(1)> Public VERB() As String
        Dim Temp As Short
        Dim Eabil As Short
        Dim TotalEngMinutes As Short
        Dim TotalMatMinutes As Short
        Dim NProbs As Short
        Dim FirstEverMatPageFileno As Short
        Dim ExtraEnglish As Short
        Dim ClassYear As Short
        Dim PrintMonthly As Boolean
        Dim LongshTest As Short
        Dim PUNC As Short
        Dim Avwords As Short
        Dim Avsents As Short

        <VBFixedString(1)> Public Home() As String
        Dim OpTest As Short
        Dim PrintAnswers As Short
        Dim HandoutTimetab As Short
        Dim IssueNumber As Short
        Dim TheTeacherIs As Short
        Dim TutorNumber As Short
        Dim HandoutFlags1 As Short
        Dim Essential As Short
        Dim EstimatedMabil As Short
        Dim IndSchool As Boolean
        Dim PreviousLastMatPage As Short
        Dim Targeting As Short
        <VBFixedString(1)> Public PaceControlledBy() As String

        <VBFixedString(2)> Public DoNext() As String
        Dim Revising As Boolean
        Dim ExtraEssential As Short
        Dim TotalMinsWork As Short
        Dim AutoTimes As Short
        <VBFixedArray(1)> Dim nstars() As Short
        Dim StarsToDate As Short
        Dim LastTestDate As Date
        Dim LastDeadLine As Date
        Dim DaysStretch As Short
        Dim NumberToPrint As Short
        Dim Fee As Short
        Dim AgeLastMatPage As Short
        Dim Deadline As Date
        Dim TestDate As Date
        Dim ExamDate As Date
        Dim ExamToCome As Boolean
        Dim EstimatedEabil As Short
        <VBFixedArray(79)> Dim DaysLate() As Short
        Dim UrgencyFactor As Single
        Dim AverageOfLastMatPages As Single
        Dim Boy As Boolean
        Dim BirthdayCardPrintedOn As Date
        Dim AvLanguage As Short
        <VBFixedArray(303)> Dim Bulletin() As Byte
        Dim PluralsAge As Single
        Dim ChoosewAge As Single
        Dim spellAge As Single
        Dim PuncAge As Single
        Dim OppositesAge As Single
        Dim ProgressChartUpdated As Boolean
        Dim FirstPrintDate As Date

        <VBFixedString(30)> Public StoredBackUpPoint() As String
        Dim WhenResetMathsPages As Short
        Dim LowestPresentNoOfResetMathsPages As Short
        Dim PresentNoAtResetOfMathsPages As Short
        Dim Pace As Short
        Dim LangNormForAge As Short
        Dim LangNormForClass As Short
        Dim MathsNormForAge As Short
        Dim MathsNormForClass As Short
        Dim AveNormForAge As Short
        Dim AveNormForClass As Short
        <VBFixedArray(3)> Dim EarlyFinishDate() As Date
        <VBFixedArray(3)> Dim LateFinishDate() As Date
        Dim YearSixYear As Short
        Dim DecimalAgeOfPupil As Single
        Dim DecimalAgeOfClass As Single
        Dim MatPageAverages As Single
        Dim EngPageAverages As Single
        Dim ExpectedMatAge As Single
        Dim AheadBy As Single
        Dim Asents As Single
        Dim Awords As Single
        Dim LangAheadBy As Single
        Dim grandtotalhoursdone As Single
        Dim SomeDataHasBeenWrittenToDisk As Boolean
        Dim MyAssessmentOfEabil As Short
        Dim MyAssessmentOfMabil As Short
        Dim ExpectedEngAge As Single
        Dim FirstEverMatPagePresentNo As Short
        <VBFixedArray(9)> Dim TestPoint() As Short
        <VBFixedArray(9)> Dim PracPoint() As Short
        <VBFixedArray(9)> Dim Age() As Single
        <VBFixedArray(9)> Dim MinsDone() As Short
        Dim PostAgeWrong As Boolean
        Dim PastStartBaseForRevision As Boolean
        Dim HighestEverMatPage As Short
        <VBFixedArray(199)> Dim DatePrinted() As Date

        <VBFixedString(94)> Public Spare2() As String
        Dim EstimatedAverageAbil As Short
        Dim PlTest As Short
        Dim Check12 As Short
        Dim LastBackUpRecordNo As Short
        Dim HalfWayImageNumber As Byte
        Dim Spare3 As Byte
        Dim NeedsExtraSpelling As Boolean

        <VBFixedString(1)> Public Spare4() As String
        <VBFixedArray(1)> Dim Spare5() As Short
        <VBFixedString(6)> Public AgeOfPupil() As String
        <VBFixedArray(1)> Dim Spare6() As Short
        <VBFixedArray(1)> Dim PrintDate() As Date
        Dim LowestMab As Byte
        Dim HighestMab As Byte
        Dim Spare7 As Short
        Dim LastMatPage As Short
        Dim PuncTest As Short
        Dim PuncPrac As Short
        Dim ChoosewTest As Short
        Dim ChoosewPrac As Short
        Dim PupilHasTest As Boolean
        Dim Unsurpassability As Boolean
        Dim TestNumber As Short
        Dim MatPagesOnlyAverage As Single
        Dim MatPagesOnlyAheadBy As Single
        Dim PuncFinished As Short
        Dim SpellFinished As Short
        Dim ChoosewFinished As Short
        Dim PlFinished As Short
        Dim OppFinished As Short
        Dim Paid As Short
        Dim Pupilosity As Boolean
        Dim Wonderfulness As Boolean
        Dim Magnitude As Boolean
        Dim Magnificence As Boolean
        <VBFixedArray(9)> Dim Flag() As Boolean
        Dim Cribs1And2 As Boolean


    End Structure

......................................

The length of the TYPE is 2762 bytes, but the length of the STRUCTURE is only 2644 bytes.

How can this be so?

Thank you.
Comment
Watch Question
This problem has been solved!
Unlock 2 Answers and 5 Comments.
See Answers
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE