?
Solved

maxLines = Form1.TextShow.Height / Form1.TextHeight("A") ?

Posted on 2003-03-02
8
Medium Priority
?
208 Views
Last Modified: 2012-05-07
I am using
maxLines = Form1.Text1.Height / Form1.TextHeight("A")
 to calculate maximum number of lines that'll fit into  the textbox (without scroll) but it doesnt seem to wrk. I have font set to courier new (western) ,size 9 and the form's scale mode is twips. Any ideas on this ..i thought i had this wrking earlier :- (
0
Comment
Question by:sambha03
[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
  • 4
  • 3
8 Comments
 
LVL 14

Expert Comment

by:aelatik
ID: 8051633
maxLines = Form1.Text1.Height / Form1.text1.text

The result is based on a "FLAT" & "BORDERLESS" textbox.
0
 

Author Comment

by:sambha03
ID: 8052855
Text1 is a textbox right? THe above code is giving:
" Error number  =13"
" Description : Type mismatch"
0
 
LVL 14

Accepted Solution

by:
aelatik earned 400 total points
ID: 8053307
Sorry,

Your solution is correct, but you have to set up a flat and borderless textbox. if not your have to use :

maxLines = clng(Form1.Text1.Height / Form1.TextHeight("A"))-1
0
Industry Leaders: 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:sambha03
ID: 8053386
Mine is a flat borderless textbox. I resize it using something like:
Me.Height = MDIForm1.ScaleHeight *.8
Text1.Height = Me.Height * 0.4
maxLines = me.Text1.Height / me.TextHeight("A")

Do you see any problem here?
0
 
LVL 14

Expert Comment

by:aelatik
ID: 8053455
Post me more of your code, this part works fine.
I'd like to understand what you want to achieve.
0
 

Author Comment

by:sambha03
ID: 8054278
I just realised that it wrks if i start a new project but not in my existing project. Thats y I wrote that I thought I had this working earlier. I think its got to do with the scaleHeight,height ,width properties.Let me work on it a bit more and I'll get back.
0
 
LVL 4

Expert Comment

by:TigerZhao
ID: 8054332
maxLines = Form1.TextHeight(Form1.Text1) / Form1.TextHeight("A")
0
 

Author Comment

by:sambha03
ID: 8054695
Got it. The original solution worked one of the nested calls was changing the font size in my code.
0

Featured Post

Enroll in August's Course of the Month

August's CompTIA IT Fundamentals course includes 19 hours of basic computer principle modules and prepares you for the certification exam. It's free for Premium Members, Team Accounts, and Qualified Experts!

Question has a verified solution.

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

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…
When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
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…
Suggested Courses
Course of the Month14 days, 1 hour left to enroll

800 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