Results 1 to 2 of 2

Thread: compile error - something with Private Type/End Type, I think

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Aug 1999
    Location
    Glasgow,Scotland
    Posts
    281

    Could someone please suggest to me why I keep getting the error:

    Compile error: Type mismatch

    I have this code in my form. When I click command1 I get the error, and this comes up highlighted:

    temp_fraction =

    ------

    Here's my code (A function in a module is being called):


    Option Explicit

    Dim sign_string As String

    Private Type Fraction_type
    numerator As Integer
    denominator As Integer

    End Type


    Private Sub Command1_Click()
    Dim topinteger As Integer
    Dim bottominteger As Integer

    Dim temp_fraction As Fraction_type
    Randomize
    Picture1.Cls
    topinteger = Int(Rnd * 20) - 10
    bottominteger = Int(Rnd * 20) - 10
    If bottominteger = 0 Then
    bottominteger = 3
    End If

    'temp fraction is highlighted
    temp_fraction = Fraction(topinteger, bottominteger)

    Call format_func(2000, 1400, "hello =", temp_fraction.numerator, temp_fraction.denominator, Picture1)

    End Sub


    ---------

    Thanks for any help!

  2. #2
    PowerPoster BruceG's Avatar
    Join Date
    May 2000
    Location
    New Jersey (USA)
    Posts
    2,628
    The function "Fraction" would have to be returning a data type of "fraction_type" (and I believe the ability of VB to return UDT's from functions is a fairly recent development - maybe only since VB6?).

    Anywho, I beleive the function header should look something like this:

    Function Fraction(i As Integer, j As Integer) As Fraction_type
    "It's cold gin time again ..."

    Check out my website here.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width