Solved

Textheight & Textwidth problem in vb6

Posted on 1999-01-17
3
2,973 Views
Last Modified: 2012-06-27
My problem is that I have several textboxes on the screen with different fonts in them and I need to evaluate there true lenght and height so as I can print them at correctly justified positions on the printers object. It seems very obvious how you should do this using the above commands but they always return the same height and width for totally different fonts. The fonts are showing to be different in the textboxes but there values stay the same on height no matter what fontsize you change them to.
0
Comment
Question by:waynecarlisle
[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
  • 2
3 Comments
 

Author Comment

by:waynecarlisle
ID: 1469061
Adjusted points to 100
0
 
LVL 10

Accepted Solution

by:
caraf_g earned 100 total points
ID: 1469062
The problem is that the TextHeight and TextWidth values depend on the font of your Form regardless of which text box you use.

There is a very easy way you could fix this:

1 Stick a picture box on the form, with border style set to none so you don't see it at run time. PS - make sure you set the tabstop property to false as well so the user can't tab into it.

2 For every text box for which you want to know the correct text height or text width:
Set Picture1.Font = Text1.Font
The text width and text height for the text in the text box can then be calculated using the TextWidth and TextHeight methods on the picture box:
correct text width = Picture1.TextWidth(Text1.Text)

0
 

Author Comment

by:waynecarlisle
ID: 1469063
caraf

Thanks,

I have spent 2 full days working on this

Wayne
0

Featured Post

Independent Software Vendors: 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!

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

726 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