Results 1 to 6 of 6

Thread: Msg box

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Aug 2004
    Posts
    344

    Msg box

    How do I centre the text in the msgbox?

    VB Code:
    1. MsgBox "Thank you" & vbNewLine & "Please contact me at 12345678 as soon as possible!", vbInformation, "Info"


  2. #2
    INXSIVE Bruce Fox's Avatar
    Join Date
    Sep 2001
    Location
    Melbourne, Australia
    Posts
    7,425

    Re: Msg box

    You have to space it out yourself, or SubClass the MsgBox.

    Alternatly, you can make your own (using Form) - its easy, do you want an example?
    Handy References:
    MSDN Library
    ADO Tutorial Excel Tutorial MZTools (VB6)

    • Please pull down the Thread Tools menu and click the 'Mark Thread Resolved' button, or alternately edit your original post and add "Resolved" or place a in the subject when your question(s) have been answered.
    • Please use code tags [highlight=vb] your code goes here between the tags [/highlight] when posting code.

  3. #3

    Thread Starter
    Hyperactive Member
    Join Date
    Aug 2004
    Posts
    344

    Re: Msg box

    Quote Originally Posted by Bruce Fox
    You have to space it out yourself, or SubClass the MsgBox.

    Alternatly, you can make your own (using Form) - its easy, do you want an example?
    Yes please.....thank you so much!

  4. #4
    VB Guru ganeshmoorthy's Avatar
    Join Date
    Dec 2005
    Location
    Sharjah, United Arab Emirates
    Posts
    3,031

    Re: Msg box

    insert a new form. place a label with the property
    VB Code:
    1. Label1.Alignment = 2 - Center
    2. Label1.WordWrap = True
    pass your message to this form like
    VB Code:
    1. frmMessageBox.Label1.Caption = "Your message goes here..."
    If an answer to your question has been helpful, then please, Rate it!

    Have done Projects in Access and Member management systems using BioMetric devices, Smart cards and BarCodes.


  5. #5
    VB Guru ganeshmoorthy's Avatar
    Join Date
    Dec 2005
    Location
    Sharjah, United Arab Emirates
    Posts
    3,031

    Re: Msg box

    and ofcourse position the label's left to the form's left and make it's width as the form's width with some margines at left and right of the label. the label's height should be to occupy 2 or 3 lines....
    If an answer to your question has been helpful, then please, Rate it!

    Have done Projects in Access and Member management systems using BioMetric devices, Smart cards and BarCodes.


  6. #6
    PoorPoster iPrank's Avatar
    Join Date
    Oct 2005
    Location
    In a black hole
    Posts
    2,728

    Center Alignment Text In a MessageBox

    VB Code:
    1. Private Sub Command1_Click()
    2.     Dim Line2 As String
    3.     Dim Line1 As String
    4.     Dim SpaceCount As Long
    5.  
    6.     Line1 = "Thank You"
    7.     Line2 = "Please contact me at 12345678 as soon as possible!"
    8.  
    9.     SpaceCount = ((TextWidth(Line2) - TextWidth(Line1)) \ TextWidth(" ")) \ 2
    10.     Line1 = Space(SpaceCount) & Line1
    11.  
    12.     MsgBox Line1 & vbNewLine & Line2, vbInformation, "Info"
    13. End Sub
    (assuming you haven't changed your default system font settings and haven't changed your Form's font setting)
    Usefull VBF Threads/Posts I Found . My flickr page .
    "I love being married. It's so great to find that one special person you want to annoy for the rest of your life." - Rita Rudner


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width