| Author |
Message |
Allen Johnson
Guest
|
Posted:
Mon Dec 06, 2004 9:31 pm Post subject:
Maximum width of text within VBA textbox control |
|
|
Does anyone have a method to find the maximum width of text within a VBA
multiline text box?
I'd like something to find the longest line of text of a note such as:
8" CONCRETE CAP SLAB
REINFORCE W/ #5 @ 8" O.C. EA WAY
ELEVATION TOP SLAB 108-0
The only property I can find is the .CurX Property.
VB has the .Textwidth method, but it doesn't appear to exist in VBA.
The reason is I'd like to size the textbox control to be fairly
representative of the maximum length of the longest line within the textbox
control.
|
|
| Back to top |
|
 |
Ed Jobe
Guest
|
Posted:
Mon Dec 06, 2004 9:37 pm Post subject:
Re: Maximum width of text within VBA textbox control |
|
|
You can use the X value of the BoundingBox property.
--
----
Ed
----
"Allen Johnson" <ajohnson@dwase> wrote in message
news:41b4897d$1_2@newsprd01...
| Quote: | Does anyone have a method to find the maximum width of text within a VBA
multiline text box?
I'd like something to find the longest line of text of a note such as:
8" CONCRETE CAP SLAB
REINFORCE W/ #5 @ 8" O.C. EA WAY
ELEVATION TOP SLAB 108-0
The only property I can find is the .CurX Property.
VB has the .Textwidth method, but it doesn't appear to exist in VBA.
The reason is I'd like to size the textbox control to be fairly
representative of the maximum length of the longest line within the
textbox
control.
|
|
|
| Back to top |
|
 |
Allen Johnson
Guest
|
Posted:
Mon Dec 06, 2004 9:39 pm Post subject:
Re: Maximum width of text within VBA textbox control |
|
|
But I actually want to know how wide the text is in the textbox, not the
drawing.
"Ed Jobe" <not.edljobe@hotmail.com> wrote in message
news:41b48ab5$1_1@newsprd01...
| Quote: | You can use the X value of the BoundingBox property.
|
|
|
| Back to top |
|
 |
Ed Jobe
Guest
|
Posted:
Mon Dec 06, 2004 10:08 pm Post subject:
Re: Maximum width of text within VBA textbox control |
|
|
I see now. How about setting AutoSize to True?
--
----
Ed
----
"Allen Johnson" <ajohnson@dwase> wrote in message
news:41b48b4e$1_1@newsprd01...
| Quote: | But I actually want to know how wide the text is in the textbox, not the
drawing.
"Ed Jobe" <not.edljobe@hotmail.com> wrote in message
news:41b48ab5$1_1@newsprd01...
You can use the X value of the BoundingBox property.
|
|
|
| Back to top |
|
 |
Allen Johnson
Guest
|
Posted:
Mon Dec 06, 2004 10:22 pm Post subject:
Re: Maximum width of text within VBA textbox control |
|
|
Good idea! Thanks.
With txtNotes
.AutoSize = True
.Text = TextString
tbw = .Width
.AutoSize = False
.Width = 1.2 * tbw
.Left = (Me.Width - .Width) / 2
.Height = 95
End With
"Ed Jobe" <not.edljobe@hotmail.com> wrote in message
news:41b4921c_1@newsprd01...
> I see now. How about setting AutoSize to True? |
|
| Back to top |
|
 |
Ed Jobe
Guest
|
Posted:
Mon Dec 06, 2004 10:47 pm Post subject:
Re: Maximum width of text within VBA textbox control |
|
|
You're welcome. Another FYI, might be to calulate it from the width of a
char (in points), multiplied by the LEN of the widest string. Although I
think you've got the easier way.
--
----
Ed
----
"Allen Johnson" <ajohnson@dwase> wrote in message
news:41b4956f$1_1@newsprd01...
| Quote: | Good idea! Thanks.
With txtNotes
.AutoSize = True
.Text = TextString
tbw = .Width
.AutoSize = False
.Width = 1.2 * tbw
.Left = (Me.Width - .Width) / 2
.Height = 95
End With
"Ed Jobe" <not.edljobe@hotmail.com> wrote in message
news:41b4921c_1@newsprd01...
I see now. How about setting AutoSize to True?
|
|
|
| Back to top |
|
 |
AKS
Guest
|
Posted:
Tue Dec 07, 2004 4:44 am Post subject:
Re: Maximum width of text within VBA textbox control |
|
|
| Don't forget to resize your form to fit your resized textbox. Sooner or later you will be resizing other items and then you may run into the frustrating problem of your newly calculated resized objects not always updating to the resized dimension. |
|
| Back to top |
|
 |
|
|
|
|