Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Microsoft Office > Access and Access VBA > Access VBA
|
Access VBA Discuss using VBA for Access programming.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Access VBA section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old April 24th, 2006, 10:04 PM
Authorized User
 
Join Date: Dec 2003
Posts: 25
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to ysiline Send a message via Yahoo to ysiline
Default Detect double line command button caption

Hi,

Does anyone got the idea that how can I check whether a command button got one line of caption or more than one line?

Wait to get helped.

Thanks,
 
Old April 25th, 2006, 06:46 AM
Friend of Wrox
 
Join Date: Mar 2004
Posts: 3,069
Thanks: 0
Thanked 10 Times in 10 Posts
Default

I am not sure what you mean by this. The button can only have one caption line, but it can be split in two if the button is sized properly. The application will only see one line no matter how many lines it is split into visually, if I understand you.

Perhaps you can check the button height instead.

Why do you need to check this? Maybe there is another way.

HTH


mmcdonal
 
Old April 25th, 2006, 10:04 PM
Authorized User
 
Join Date: Dec 2003
Posts: 25
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to ysiline Send a message via Yahoo to ysiline
Default

Well, thank you mmcdonal.

I did the solution using "Instr" function to search for the "vbcrlf" in the caption of button.

Regard,

 
Old April 26th, 2006, 01:47 AM
Authorized User
 
Join Date: Mar 2006
Posts: 80
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi,
if you caption text is longer than width of Button, then will be split to two lines automatically without any newline symbol (e.g. vbNewLine, or other).
But, if you would like to search exact phrase vbNewLine in caption text, syntax is:

Dim position As Long
position = InStr(1, Button.Caption, vbNewLine, vbBinaryCompare)

If position > 0 Then
'there is more lines in text
End If

Peko

 
Old April 26th, 2006, 06:30 AM
Friend of Wrox
 
Join Date: Mar 2004
Posts: 3,069
Thanks: 0
Thanked 10 Times in 10 Posts
Default

Thanks for that. I didn't know about vbNewLine (I usually use vbCrLf when I need this, but I haven't used it in button text.


mmcdonal
 
Old April 26th, 2006, 09:30 PM
Authorized User
 
Join Date: Dec 2003
Posts: 25
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to ysiline Send a message via Yahoo to ysiline
Default

Ya, I get used to "vbCrlf" and it is good to get an easier one with "VbNewLine"

Thank,






Similar Threads
Thread Thread Starter Forum Replies Last Post
Change button caption on continuous subform PeregrinTook Access VBA 2 April 16th, 2007 05:16 PM
do a double perl replace in one line crmpicco Perl 4 March 16th, 2007 08:53 AM
Control button caption and visible property chacquard Access VBA 7 September 9th, 2005 11:14 AM
Want to detect line breaks conundrum Classic ASP Basics 1 October 3rd, 2003 04:05 AM
How to detect window Close (X) Button cyberjames2003 Javascript How-To 2 July 27th, 2003 08:13 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.