Solved

An object question

Posted on 2002-03-17
6
162 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

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

There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
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…

732 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