[Gambas-user] Formatting a TextBox
Jeffrey Cobb
maillists.gurulounge at ...626...
Mon Feb 4 02:13:02 CET 2008
I was thinking about that... unfortunately I had to run this morning --
and actually have to leave again soon... so I threw this code snippet
together.
But I as thinking about storing the contents of what the user types in a
string variable then when the contents are changed to update the textbox
with the new "formatted" text. Like I said... would take a little more
extensive programming. Probably useful enough to store in a sub
somewhere and pass a textbox control and string contents to it...
allowing it to be used by ANY textbox.
Will probably work on it tonite when I get home assuming no one else has
solved it.
Take Care,
Jeff
On Sun, 2008-02-03 at 17:31 -0500, =?utf-8?B?UGlyYW1peCBUZWNub2xvZ
+1hcw==?= wrote:
> 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
>
> >
>
>
More information about the User
mailing list