Results 1 to 10 of 10

Thread: Alignment in textfields

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Jul 2000
    Location
    Italy
    Posts
    90

    Unhappy

    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.

  2. #2
    Monday Morning Lunatic parksie's Avatar
    Join Date
    Mar 2000
    Location
    Mashin' on the motorway
    Posts
    8,169
    It could be a problem with language settings (reading R2L and all that).
    I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
    -- Linus Torvalds

  3. #3
    PowerPoster BruceG's Avatar
    Join Date
    May 2000
    Location
    New Jersey (USA)
    Posts
    2,657
    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.
    "It's cold gin time again ..."

    Check out my website here.

  4. #4

    Thread Starter
    Lively Member
    Join Date
    Jul 2000
    Location
    Italy
    Posts
    90
    Ok thanks! I'll trying doing so... (but that's really
    stupid! Why did MS implement it this way... bha!). Thanks a lot!

  5. #5
    Guest
    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

  6. #6

    Thread Starter
    Lively Member
    Join Date
    Jul 2000
    Location
    Italy
    Posts
    90
    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

  7. #7
    Monday Morning Lunatic parksie's Avatar
    Join Date
    Mar 2000
    Location
    Mashin' on the motorway
    Posts
    8,169
    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.
    I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
    -- Linus Torvalds

  8. #8

    Thread Starter
    Lively Member
    Join Date
    Jul 2000
    Location
    Italy
    Posts
    90
    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?

  9. #9
    Guest
    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

  10. #10

    Thread Starter
    Lively Member
    Join Date
    Jul 2000
    Location
    Italy
    Posts
    90

    OK!

    Ok, i'll do that this way! Thanks a lot!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width