HOWTO: Right Justify/Center Text in Single-Line Text ControlID: Q111952
|
To center or right justify (align) the text in a text control that contains a single line of text, set the multiline property to True and the Alignment property to the desired value. Then trap the KeyPress event and use the multiline and MaxLength properties to trap the carriage return and convert it to another character.
Sub Text1_KeyPress (KeyAscii As Integer)
If KeyAscii = 13 Then
KeyAscii = 7 ' Beep - no effect on text
End If
End Sub
Add the following code to the Load event procedure of Form1:
Sub Form_Load()
Dim boxht as Double
boxht = Text1.Height
Text1.Height = Text1.Height * 2
'This is to make sure the text will appear in the box
Text1.Height = boxht
End Sub
Additional query words: 3.00 align format textbox
Keywords : kbcode kbCtrl kbVBp300 kbVBp400
Version : 3.00 4.00
Platform : WINDOWS
Issue type :
Last Reviewed: June 21, 1999