
Type mismatch on user defined data type
I've been writing some small VB4 16-bit routines to learn how to do disk I/O.
I'm getting a type mismatch error that I don't understand.
In DiskIO.bas I have the following:
Option Explicit
'File Record definitions
'File headers
Public Type FileHeader
Space As String * 1
NumRecords As String * 10
LastDeleteNr As String * 10
End Type
'Routine to open the Name file and return the header
'The file is left open
'
Public Sub GetNameFileHeader(ByRef FileName As String, ByRef HeaderData As
FileHeader)
Open FileName For Random As #1 Len = Len(HeaderData) 'Open file
Get #1, 1, HeaderData 'Read the header
End Sub
In a simple form that has a text box for the path and an OK button, I have the
following:
Option Explicit
Private Sub cmdOK_Click()
Dim Header As FileHeader
Dim FileName As String
'Open the name file & get the header
FileName = txtFileName.Text
Call GetNameFileHeader(FileName, Header)
End Sub
When I do a shift-F9 watch on Header in cmdOK or on HeaderData in the
subroutine, I get a type mismatch. I've spent about three hours going through
the language manual to check my code, but I don't see my error. The
Len(HeaderData) and a Len(Header) give the correct value of 21.
I'm really confused, so if anyone can help me see my error(s), I'll be
grateful.
/Allen