Type mismatch on user defined data type 
Author Message
 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



Sun, 20 Sep 1998 03:00:00 GMT  
 Type mismatch on user defined data type
I finally figured out my problem.  Simple once I understood it :-)

VB can't handle a watch put on a record that contains multiple fields.  It
works fine if I put separate watches on each field.  

Also, we can't put a watch on an array in a DIM statement.  This time,
however, the error message stated that watches couldn't be put on arrays.  
That makes more sense since arrays are usually large.  It would be nice if a
watch could be put on a complete record and display each field.  Oh well....

/Allen



Mon, 21 Sep 1998 03:00:00 GMT  
 Type mismatch on user defined data type

Quote:

> 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

'Space' is a VB function (or sub...one of the two).  Within your UDT,
change the name of that field to something else and give it a try.
--
Deets Consulting



Mon, 21 Sep 1998 03:00:00 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. Q: variant data type with user defined data type

2. Passing user data type to function causes type mismatch error

3. Prob. w\ TYPE data type: err:Type Mismatch

4. Compile error: User-defined data type not defined!

5. User Control - User-defined type not defined

6. VB4: Help: data-alignment in user defined data types

7. Help: data-alignment in user defined data types

8. Passing Array or a user defined data type as a parameter to a storedprocedure in Oracle

9. HELP user defined data types

10. visual basic user defined data types

11. Assigning recordset recodset to a user Defined Data Type

12. binary files and user defined data types

 

 
Powered by phpBB® Forum Software