[Gambas-user] Formatting a TextBox
=?utf-8?B?UGlyYW1peCBUZWNub2xvZ+1hcw==?=
piramix at ...178...
Sun Feb 3 23:31:29 CET 2008
Thanks Jeff for the code. It's useful. But would be nice to have the mask already into the text box; this way the user knows what to type there. Not only for phone numbers, could be for anything else, let's say product keys, credit card numbers, etc. Is possible or your solution is the only one available here?
Greeetings,
Pablo.
> ----- Original Message -----
> From: "Jeffrey Cobb" <maillists.gurulounge at ...626...>
> To: "mailing list for gambas users" <gambas-user at lists.sourceforge.net>
> Subject: Re: [Gambas-user] Formatting a TextBox
> Date: Sun, 03 Feb 2008 12:31:35 -0800
>
> 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.
> >
>
>
> -------------------------------------------------------------------------
> This SF.net email is sponsored by: Microsoft
> Defy all challenges. Microsoft(R) Visual Studio 2008.
> http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
> _______________________________________________
> Gambas-user mailing list
> Gambas-user at lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/gambas-user
>
--
Want an e-mail address like mine?
Get a free e-mail account today at www.mail.com!
More information about the User
mailing list