Set lable caption centered
I have VB6 app which I want to change the value in the caption for a label. I can set the properties while coding the form and set alignment = center and the caption looks fine. But when I issue a LblStatusGPSAlert.Caption = "Test" the caption that was there before and centered is replaced with "Test" but it is left justified. Any ideas on how to keep it centered since I did not change the alignment properties?
Thanks
[428 byte] By [
Don] at [2007-11-11 7:55:29]

# 1 Re: Set lable caption centered
I am not able to reproduce the behavior you describe. I created a form with a label (Label1) and set its Alignment property to Centered. In the Form_Click event, I change Label1.Caption to "Hello"; the caption remains centered.
Can you reproduce the problem in a simple project like the one I described? If not, I suspect that something is, in fact, changing the Alignment property in your app.
# 2 Re: Set lable caption centered
I tried a simple app and it worked there. The app I am having a problem with has no code which changes the alignment. It only sets the caption to values found in the field from a SQL table. Does the caption react differently to numeric values?
Don at 2007-11-11 17:27:22 >

# 3 Re: Set lable caption centered
I don't think so. Did you try a numeric value in your test app? Could the database values have trailing spaces that throw off the alignment?