-
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!
-
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