Solved

An object question

Posted on 2002-03-17
6
161 Views
Last Modified: 2010-05-02
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

0
Comment
Question by:posnorm
6 Comments
 
LVL 2

Expert Comment

by:nahumd
ID: 6876115
Try to define the objects picPreview and objPrint not as objects , but as their exact type.
0
 
LVL 44

Expert Comment

by:bruintje
ID: 6876118
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

0
 
LVL 2

Accepted Solution

by:
peterwest earned 100 total points
ID: 6876194
It might be worth changing the control name from Picture to Picture1 or something else.  I think that Form1.Picture normally refers to the Picture property of the form - so if you've got a control with the name Picture then it could cause problems.

There is also a problem with your declarations.  You declare objPrint as an Object but then try to pass it to the scale routine which is expecting a PictureBox object.  You could either:

1. Change the parameter required for the scaling to be an object too.

or

2. Change the declaration of objPrint to PictureBox.

You'd probably find the programme works quicker with the second option.  If you declare items as objects then late binding is used which can slow the application down.

Hope this helps,

Pete
0
Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
LVL 13

Expert Comment

by:crazyman
ID: 6876758
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.
0
 
LVL 1

Expert Comment

by:Barraza
ID: 6878891
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
0
 

Author Comment

by:posnorm
ID: 6887859
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
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Saving history changes to sub form 4 48
bit defender blocks good applications 2 101
Hide vba in gp 7 106
VB6 ListBox Question 4 49
Introduction I needed to skip over some file processing within a For...Next loop in some old production code and wished that VB (classic) had a statement that would drop down to the end of the current iteration, bypassing the statements that were c…
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

828 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question