MsgBox Question

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I hope this is the appropriate group for my question. If not please let me
know.

I have the following statements to display a message to the user:
User_message_2 = "1) All Tables will be transferred"
User_message_2a = " B_AFFILIATION B_AREAOFINTEREST"
User_message_2b = " B_LANGUAGE B_PAYCODES"
User_message_2c = " B_PLANTYPE B_SPECIALTY"
Confirm_Message = User_message_2 & vbCrLf & _
User_message_2a & vbCrLf & _
User_message_2b & vbCrLf & _
User_message_2c & vbCrLf
MsgBox(Confirm_Message, 1 + 16, "WARNING")

The lines appear to be spaced the way I want them to look on screen, but
when the code runs, the "columns" are not aligned.

I have played with using tabs or space characters to build these lines but
nothing seems to allow the alignment I want. The only thing that works is to
"misalign" the code lines to that the screen is aligned.

Has anyone seen this before and how did you get around the problem?

Thanks.
 
I don't believe there's a way to use tabs with message boxes.

You could create your own form that looks like a message box, with multiple
textboxes that are aligned the way you want.
 
By default, the VBA IDE displays code in the Courier New font, which is a
fixed-space font, meaning that all letters take up the same amount of
horizontal space. But the message box will be displayed using a proportional
font, in which thin letters such as "i" take up much less horizontal space
then wide letters such as "M" or "W". Therefore text that appears to line up
when using the fixed-width font will not line up when using the proportional
font.

I'm not aware of a way to change the font used by the message box without
changing it system-wide, and I wouldn't recommend that. You could use a form
instead of a message box, or just use commas as separators instead ...

B_AFFILIATION, B_AREAOFINTEREST
B_LANGUAGE, B_PAYCODES
B_PLANTYPE, B_SPECIALTY

To my eyes, the way you are trying to align the text is only slightly more
readable. I doubt many users will notice the difference.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top