VB Method to Center Text Horizontal

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

Guest

This should be simple, but I can't seem to find the code or method to center
text in a control horizontally. I know you can do it manually through the
properties, but I need to capture it in an IF statement.
 
Use the TextAlign property

Me.txtSubject.TextAlign = 2

'0,1,2,3 = general, left, center, right
 
I don't understand what you mean by "capture it in an IF statement"

To programmatically set a text box to centred, use:

Me!MyTextBox.TextAlign = 2

(General Alignment is 0, Left Aligned is 1 and Right Aligned is 3)
 

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