VB Method to Center Text Horizontal

C

Cydney

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.
 
J

John Spencer

Use the TextAlign property

Me.txtSubject.TextAlign = 2

'0,1,2,3 = general, left, center, right
 
D

Douglas J. Steele

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)
 
Top