Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

ScaleLeft and ScaleTop

Posted on 2003-12-11
6
Medium Priority
?
1,774 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
Technology Partners: 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!

 

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

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

I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
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…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Suggested Courses

824 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