posnorm
asked on
An object question
Using VB5. What is wrong with the following code? The offending code line is indicated with the error thrown:
=======
Module1.bas
Public objPrint As Object
=======
Private Function ScaleInches _
(picPreview As PictureBox) As Double
Dim Ratio As Double
---
---computations
---
ScaleInches = Ratio
End Function
=======
Private Sub cmdPreview_Click()
Dim dRatio as Double
Set objPrint = frmPreview.Picture
' frmPreview is another form, containing a picture box,
' named Picture
'
' The following line throws the error:
' " 13 type mismatch"
dRatio = ScaleInches(objPrint)
End Sub
======
I tried changing the Function definition to:
Private Function ScaleInches _
(picPreview As Object) As Double
Then, inside that function, the following code line:
picPreview.ScaleMode = vbInches
throws the error: "438 Object doesn't support this property or method".
=====
Please help -- Norm
=======
Module1.bas
Public objPrint As Object
=======
Private Function ScaleInches _
(picPreview As PictureBox) As Double
Dim Ratio As Double
---
---computations
---
ScaleInches = Ratio
End Function
=======
Private Sub cmdPreview_Click()
Dim dRatio as Double
Set objPrint = frmPreview.Picture
' frmPreview is another form, containing a picture box,
' named Picture
'
' The following line throws the error:
' " 13 type mismatch"
dRatio = ScaleInches(objPrint)
End Sub
======
I tried changing the Function definition to:
Private Function ScaleInches _
(picPreview As Object) As Double
Then, inside that function, the following code line:
picPreview.ScaleMode = vbInches
throws the error: "438 Object doesn't support this property or method".
=====
Please help -- Norm
Try to define the objects picPreview and objPrint not as objects , but as their exact type.
Hi posnorm,
The first error on the type mismatch error 13 comes probably with using the object in the function, returning a double and putting it into a double could get to that message i guess....
The second error is the start of the trouble it seems that the scalemode property of the picturebox isn't supported
i couldn't find anything except on grids or the printer object about this error with scalemode and they had to be patched with service packs
maybe this is the solution for your problem too, but i'm not sure
http://msdn.microsoft.com/vstudio/downloads/updates/sp/vs97/readme.asp
:O)Bruintje
The first error on the type mismatch error 13 comes probably with using the object in the function, returning a double and putting it into a double could get to that message i guess....
The second error is the start of the trouble it seems that the scalemode property of the picturebox isn't supported
i couldn't find anything except on grids or the printer object about this error with scalemode and they had to be patched with service packs
maybe this is the solution for your problem too, but i'm not sure
http://msdn.microsoft.com/vstudio/downloads/updates/sp/vs97/readme.asp
:O)Bruintje
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
you are trying to change the scale mode of
frmPreview.Picture
this will be looking at the picture property of your form not your picture box, change its name.
frmPreview.Picture
this will be looking at the picture property of your form not your picture box, change its name.
Try removing the "As Double" from your function name and from the variable inside your function. Let them be Variants. For example...
Private Function ScaleInches (picPreview As PictureBox)
Dim Ratio
.....
....
End Function
Private Function ScaleInches (picPreview As PictureBox)
Dim Ratio
.....
....
End Function
ASKER
I wish to thank everyone for their interest in this question. I have learned something from each comment. There is no way to split up points.
The matter of early vs late binding is important, and I am familiarizing myself with the concept.
Thank you all again. -- Norm
The matter of early vs late binding is important, and I am familiarizing myself with the concept.
Thank you all again. -- Norm