Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

An object question

Posted on 2002-03-17
6
Medium Priority
?
166 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 400 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
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
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

Ask an Anonymous Question!

Don't feel intimidated by what you don't know. Ask your question anonymously. It's easy! Learn more and upgrade.

Question has a verified solution.

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

The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
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…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Suggested Courses

610 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