Solved

ScaleLeft and ScaleTop

Posted on 2003-12-11
6
1,734 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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 

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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

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

Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
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…
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
Course of the Month5 days, 3 hours left to enroll

635 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