Uppercase on textfield on realtime

Hi all!

I know how to convert the text on a TextField to Uppercase like this:

Textfield1.text.uppercase.

But I want to make something like a Mask, when I type text on the TextField it converts automatically to Uppercase in realtime.
Is this possible?

Thanks

I found it:

me.text = me.text.uppercase on Textchange event

Be sure to preserve your SelStart and SelLength or your cursor will always jump to the end of the text.

Yeah you are right on Windows when I write , It jumps to the start

But how to do this, I think to do this: TextArea1.SelStart=0

Sub TextChange()
dim i as integer = me.SelStart
me.text = Uppercase( me.text )
me.SelStart = i
End Sub

[quote=227800:@Gerardo García]But I want to make something like a Mask, when I type text on the TextField it converts automatically to Uppercase in realtime.
Is this possible?[/quote]

  • SO why not just set the TextField Mask to > (ie. the greater sign)???

[quote]

Convert all the characters that follow to uppercase.
Uppercasing works beyond the ASCII range where appropriate, e.g., ü becomes Ü. For example, the mask “>&&-#####” accepts the string “li20520” and returns “LI-20520”.

[quote]

No muss no fuss, no needing to keep track of things

[quote=231228:@Dave S]* SO why not just set the TextField Mask to > (ie. the greater sign)???

[quote]

Convert all the characters that follow to uppercase.
Uppercasing works beyond the ASCII range where appropriate, e.g., ü becomes Ü. For example, the mask “>&&-#####” accepts the string “li20520” and returns “LI-20520”.

[quote]

No muss no fuss, no needing to keep track of things[/quote]

There is a long standing issue with this; if you set the mask value to ‘>’ it does indeed capitalize the content, but this is at the expense of LimitText, which no longer works.

ok… then work around THAT bug, instead of setting the case of the entire string each time

put this in KEY DOWN

  if key>=chrb(8) and key<=chrb(13) then return true
  if me.text.len=me.LimitText And me.limittext>0 then return true
  return false

What about paste or drag and drop?

Fine… discount my attempts to provide a workaround

I hope you’re kidding, but I can never tell.

If you need an uppercase-only textfield more often, it would be a good idea to subclass the standard control.

Sub TextChange()
  If Me.Text.Len > Me.LimitText Then
    Me.Text = Left(Me.Text, Me.LimitText)
    Beep
  End If
End Sub

:slight_smile: