[Gambas-user] Formatting a TextBox

Jeffrey Cobb maillists.gurulounge at ...626...
Sun Feb 3 21:31:35 CET 2008


Without a little more extensive programming you may probably have to
format the phone number when the textbox looses focus.  I tried this:

PUBLIC SUB TextBox1_LostFocus()
DIM tmpStr AS String
DIM ch AS String
DIM i AS Integer

  tmpstr = ""

' ** Strip out non-numeric character  
  FOR I = 1 TO Len(TextBox1.Text)
    ch = Mid(TextBox1.text, i, 1)
    IF ((ch >= "0") AND (ch <= "9")) THEN 
      tmpstr = tmpStr & ch
    ENDIF 
  NEXT 
  
' ** Format the numeric string as a typcical US number
  tmpStr = "(" & Left(tmpstr, 3) & ") " & Mid(tmpStr, 4, 3) & "-" &
Mid(tmpStr, 7)
  TextBox1.Text = tmpstr

END


On Sun, 2008-02-03 at 14:07 -0500, Piramix Tecnologías wrote:
> Hi everybody.
> I'm trying to format a TextBox so the user can enter text into what I call a mask. I.e. to input a phone number it consists on two parts, area code and pure number, so the mask will be like this: (999)-(999-9999); note that parentheses and dashes should appear in the textbox.Is this possible? How can I do that?
> Thanks in avdance.
> Greetings.
> 
> Pablo.
> 





More information about the User mailing list