Changing Textbox Alignment at run-time

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance



Hi,
I' using VB6-SP6
I noticed the following bug when that changing a Textbox Alignment property
at run-time: for a short moment the Textbox name (i.e. 'MyTextBox'), flashes
through the box!!

To reproduce this bug, do the following:

1. Open a new VB6 project and put a Textbox on the main form
2. Set the Text property to blank and re-name this textbox to MyText
3. Put he following line in Change event:

Private Sub MyText_Change()
If MyText.Text = "MyText" Then MsgBox "VB6 textbox alignment issue."
End Sub

Now add a button (Command1) on the form with the following code in Click
event:

Private Sub Command1_Click()
If MyText.Alignment = vbLeftJustify Then
MyText.Alignment = vbCenter
Else
MyText.Alignment = vbLeftJustify
End If
End Sub

Run the project and click on Command1 button.
You should see the message popping up every time, textbox being empty.

Is there any way to avoid this bug and correctly set a Textbox alignment at
run-time, maybe using API calls?

Thank you for your help,
Marc R. - programmer
.


Quantcast