-
Hi! I am experiencing a lot of troubles with a program of mine. I have used in this program a pair of textfield, setting "Alignment" property to RightJustify for each one. On my PC everything works well, all texts are aligned on the right side, but, on other computers, each textfield becomes aligned on the left. What could the problem be given by? Maybe it is OS dipendent? Maybe i forgot any DLL in the package?
Thanks.
-
It could be a problem with language settings (reading R2L and all that).
-
I've had this problem before, too (it worked on Win 95 but not 98, or vice-versa, I don't remember which). But anyway, the problem boils down to this:
According to MS, the Alignment property of a TEXTBOX control only has effect when its MULTILINE property is set to true - otherwise, the text will always be aligned LEFT (as we've seen, it doesn't always happen that way, but this is the way it is documented).
In short, for your program to work on different computers with different OS's, change the Multiline property of these textboxes to True.
-
Ok thanks! I'll trying doing so... (but that's really
stupid! Why did MS implement it this way... bha!). Thanks a lot!
-
To make multiline TextBox act like a non-multiline TextBox, insert this code into the KeyPress event.
Code:
Private Sub Text1_KeyPress(KeyAscii As Integer)
'Set KeyAscii to 0
If KeyAscii = 13 Then KeyAscii = 0
End Sub
-
Hi Megatron,
The problem is that i have already used keypress to manage
some keyboard events, so i cannot use it this way; isn't it
the same thing if I set the MaxLenght property to the total
number of chars in a single-line-length?
Thanx
-
No. Megatron's code prevents you from typing a return (ASCII 13) into the text box. It doesn't limit the TOTAL number of characters.
-
Well, you're right! But I have already assigned to the enter
key another function (i.e. evaluating an expression) linking that to a button (i.e. the =). Is the problem solved this way?
-
You can do both.
Code:
Private Sub Text1_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
'Prevent Enter from being pressed
KeyAscii = 0
'Call your sub
Call MySub
End If
End Sub
-
OK!
Ok, i'll do that this way! Thanks a lot!