How to center text in a Messagebox?

Asked

Viewed 952 times

1

Right now I have this code:

MessageBox.Show("Verificação da password incorreta \n Insira novamente");

And the output gets like this:

Verificação da password incorreta
Insira novamente

How do I make for the output be centered on the MessageBox?

2 answers

1


There’s no way. The component wasn’t designed for this.

The solution is to use something else. It can be a message box that you develop.

Has some examples in the Code Project (also) and in the OS and at MSDN. No one does what they want, but it gives you an idea of what you need to do, but you have one that is near.

Another solution is not to centralize, think if you really need this.

0

MsgBox "O RELÓGIO" _
    & Chr(13) & "Cassiano Ricardo" _
    & Chr(13) _
    & Chr(13) & Chr(9) & "Diante de coisa tão doida" _
    & Chr(13) & Chr(9) & "Conservemo-nos serenos" _
    & Chr(13) & Chr(9) & "Cada minuto da vida" _
    & Chr(13) & Chr(9) & "Nunca é mais, é sempre menos" _
    & Chr(13) _
    & Chr(13) & Chr(9) & "Ser é apenas uma face" _
    & Chr(13) & Chr(9) & "Do não ser, e não do ser" _
    & Chr(13) & Chr(9) & "Desde o instante em que se nasce" _
    & Chr(13) & Chr(9) & "Já se começa a morrer.", 16, _
    "                         M   E   N   S   A   G   E   M"
  • Welcome to stackoverflow Serafim. Could you add more details about your answer? Talk a little bit about the method you used, answers with only code may not be very attractive

  • You could at least add a brief explanation of the above code?

  • Dear developers, I concatenate the text, broken so the instructions are aesthetically clear, with the Ascii: Chr(13) = "jumps line"; and Chr(9) = "Indents text. After the first comma I use code 16 ("Displays the Critical Message icon.") and after the last comma, there is no way, calibro with spaces to write the titles, okay? Use verses before the "End Sub" to know if the programming is performing correctly and to interrupt and see if the variables employed are with the desired values. Sincerely, Serafim

Browser other questions tagged

You are not signed in. Login or sign up in order to post.