Solved

ScaleLeft and ScaleTop

Posted on 2003-12-11
6
1,678 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
Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

 

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

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

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

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…
Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
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…
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…

832 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