Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

ScaleLeft and ScaleTop

Posted on 2003-12-11
6
Medium Priority
?
1,753 Views
Last Modified: 2007-12-19
Hi !
How can I apply this VB 6 code in VB.NET ?
    Me.ScaleTop = 30
    Me.ScaleLeft = 20

Thanks a lot :)
0
Comment
Question by:ahchong
[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
  • 3
  • 3
6 Comments
 
LVL 42

Expert Comment

by:frodoman
ID: 9919857
Scalemode isn't supported in .Net.  See text below from the Visual Studio help file:

=============

In Visual Basic 6.0, the ScaleMode property could be used to change the coordinate system for a form or PictureBox control from the default scale of twips.

Visual Basic .NET does not support multiple coordinate systems; only pixels are supported. During upgrade, coordinates are automatically converted from twips to pixels; code that sets the ScaleMode property at run time will cause a compilation error and must be modified.

Note   The upgrade tool assumes that the design-time setting for the ScaleMode property was twips; if this is not the case, the conversion will be incorrect and must be fixed.
What to do next

Remove the line of code that sets the ScaleMode property.
Review any code that was based on the ScaleMode property and modify any calculations as necessary. For example, the following code shows how to modify a procedure that used a ScaleMode of inches.
' Visual Basic 6.0
Form1.ScaleMode = vbInches
Text1.Move 2, 1
The above procedure moves the text box 2 inches right and 1 inch down from the upper left corner of the form.

' After upgrade to Visual Basic .NET
'UPGRADE ISSUE: Constant vbInches was not upgraded.
'UPGRADE ISSUE: Form property Form1.ScaleMode is not supported.
' The next line must be removed in order to compile.
Form1.ScaleMode = vbInches
' Twips are converted to pixels, but the original inch values are used.
Text1.SetBounds(VB6.TwipsToPixelsX(2), VB6.TwipsToPixelsX(1),…
After upgrade, the procedure moves the text box right by 2 pixels and down by 1 pixel — not the desired result.

' Modified Visual Basic .NET code
' Removed the ScaleMode line.
' Convert the scale (1 inch = 1440 twips).
Text1.SetBounds(VB6.TwipsToPixelsX(2880), VB6.TwipsToPixelsX(1440),…
By multiplying the inches by 1440, the twips to pixel conversion now gives the same result as in the original Visual Basic 6.0 code.

0
 

Author Comment

by:ahchong
ID: 9920838
Thanks for your comment :)
I have read the help file before, but I don't know how to apply this, can you give me the code ? (that means how to convert it to VB.NET)
0
 
LVL 42

Expert Comment

by:frodoman
ID: 9920895
ahchong,

You can't do it - it simply isn't supported any longer.

I'm guessing that you're trying to designate the upper left corner as (30,20) - simply can't be done in .Net, the upper left corner is always going to be (0,0).

Is there something you're trying to accomplish that you can't get done?

0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 

Author Comment

by:ahchong
ID: 9927504
I need it because I am doing a Math program which let other people draw on it with pen (just like the paint brush) and calculate its centroid, moment of inertial, area... . So I want to make the centre of the form be (0,0) just like our graph (last time I am using VB6, so I simply make the centre be 0,0 by using scaleLeft and scaleTop).
0
 

Author Comment

by:ahchong
ID: 9927511
by making the centre of the form be (0,0) will make my work more convenience :)
0
 
LVL 42

Accepted Solution

by:
frodoman earned 400 total points
ID: 9928041
Yes, I understand why you would do this.  Sadly this is no longer possible with .Net so your project will have to involve slightly more work ;-)

Have fun!
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say 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

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…
This article describes how to use a set of graphical playing cards to create a Draw Poker game in Excel or VB6.
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 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…
Suggested Courses

721 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