Multi-line command-button lable?

Posted on 2005-04-23
Last Modified: 2013-12-03
I wish to have a command button which displays something like this:
+         Good            +
+      Afternoon        +

Where the lable is split over two lines, and the words "Reasonably" centered.
And I'm not fully sure which fonttype I'll use for the button, could be Courier, could be Tahoma, could be anything really.

Now in the developing environment, I have no problem with adding spaces and removing them to visually lay it out, I've done that no problem...  The problem comes in when the SYSTEM FONT SIZE changes.  System-font size, the one that is set through the Screen properties (one of the tabs one comes across when changing the screensaver or themes and such) {In XP, this is the monitor-advanced "DPI settings, normal/large", in other windows versions its the "Small fonts, large fonts or NNN% sized fonts)

When the System font size gets changed, the same space-padded lable generates an output like the following
+      Good               +
+  Afternoon            +

I currently have a function which will return true/false if the system is in NormalFonts (small) or LargeFonts (large), I'm not really interested in custom-sized system font displays at this time, but for completeness, I might be later.  I can choose between two different strings which I have to develop in designtime with my computer in each mode, and pick the lable that way, which is the current way I am using, but a way I wish to replace because its dependant on the design-time conditions.

I wish to have a routine that will stamp the lable onto the command bar using TWO STRING COMPONENTS Line1 and Line2.
The assumptions / intentions to be used:
-- Line1 and Line2 will both be narrower than the command button, no wrapping will occur
-- Font type nonspecific, so should be based on character width of the strings when chosen
-- Even if line1+line2 text < width of button, STILL to be shown as two lines
-- Needs to work in both large and small font modes

I know a solution is just out of my reach, or I'm not looking at something right.
No third-party controls, please, even if you really like one...

Question by:GPrentice00
    LVL 37

    Accepted Solution

    Hi GPrentice00,

    Add this to the load event...

    Private Sub Form_Load()
        Command1.Caption = "Good" & vbCr & "Afternoon"
    End Sub

    LVL 37

    Expert Comment

    by:Harisha M G
        vbCr, vbLf, vbCrLf -- any one of these will do the job
    LVL 6

    Author Comment

    of course it would be that obvious - I tried the VBCR and VBCRLF before, but there was something else with my stupid button that must have caused a problem, making me go down the winding road...

    Featured Post

    Do You Know the 4 Main Threat Actor Types?

    Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

    Join & Write a Comment

    Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
    Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
    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…
    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…

    754 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

    Need Help in Real-Time?

    Connect with top rated Experts

    17 Experts available now in Live!

    Get 1:1 Help Now