Solved

ScaleLeft and ScaleTop

Posted on 2003-12-11
6
1,653 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
  • 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
Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

 

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 100 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

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
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…
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…
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…

757 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

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now