+ Reply to Thread
Results 1 to 6 of 6

Textbox Format

  1. #1
    Forum Contributor
    Join Date
    01-19-2006
    Posts
    142

    Textbox Format

    Hi all,

    I have a textbox on my userform and neeeeed it formatted. When the user enters it I want them to enter a 10 digit number only but also have it display a '-' in the middle of the number.

    for example,

    #####-##### (the textbox should always display the '-' in the middle of the textbox. Is this possible? I have previously tried:

    Please Login or Register  to view this content.
    but have had no joy, any help would be much appreciated.

    Taa in advance!

  2. #2
    Ian
    Guest

    Re: Textbox Format

    Possibly not the most elegant method, but this will put a - immediately
    after the 5th character in TextBox1

    Private Sub TextBox1_Change()
    If Len(TextBox1.Text) = 5 Then TextBox1.Text = TextBox1.Text & "-"
    End Sub


    --
    Ian
    --
    "gti_jobert" <[email protected]> wrote
    in message news:[email protected]...
    >
    > Hi all,
    >
    > I have a textbox on my userform and neeeeed it formatted. When the user
    > enters it I want them to enter a 10 digit number only but also have it
    > display a '-' in the middle of the number.
    >
    > for example,
    >
    > #####-##### (the textbox should always display the '-' in the middle of
    > the textbox. Is this possible? I have previously tried:
    >
    >
    > Code:
    > --------------------
    > txtPartno.Text = Format(txtPartno.Text, "#####-#####")
    > --------------------
    >
    >
    > but have had no joy, any help would be much appreciated.
    >
    > Taa in advance!
    >
    >
    > --
    > gti_jobert
    > ------------------------------------------------------------------------
    > gti_jobert's Profile:
    > http://www.excelforum.com/member.php...o&userid=30634
    > View this thread: http://www.excelforum.com/showthread...hreadid=502886
    >




  3. #3
    Forum Contributor
    Join Date
    01-19-2006
    Posts
    142

    Textbox Masking

    Hi again,

    Thanks for the promt reply! I have tried what you have suggested and works quite well. I'm not sure if it can be done in VBA, but is there a way of using an activex control to mask the textbox? I may have seen somewhere on the web that it can be done in VB6?!

    Does anyone know how to do it in VBA?

    Thanks Again!

  4. #4
    Ian
    Guest

    Re: Textbox Format

    I'm confused by your response as my suggestion IS in VBA.

    --
    Ian
    --
    "gti_jobert" <[email protected]> wrote
    in message news:[email protected]...
    >
    > Hi again,
    >
    > Thanks for the promt reply! I have tried what you have suggested and
    > works quite well. I'm not sure if it can be done in VBA, but is there a
    > way of using an activex control to mask the textbox? I may have seen
    > somewhere on the web that it can be done in VB6?!
    >
    > Does anyone know how to do it in VBA?
    >
    > Thanks Again!
    >
    >
    > --
    > gti_jobert
    > ------------------------------------------------------------------------
    > gti_jobert's Profile:
    > http://www.excelforum.com/member.php...o&userid=30634
    > View this thread: http://www.excelforum.com/showthread...hreadid=502886
    >




  5. #5
    Dave Peterson
    Guest

    Re: Textbox Format

    gti_jobert wanted to know if he/she can mask the textbox so that the format can
    be "built-in".

    Excel's textboxes don't support this.

    Ian wrote:
    >
    > I'm confused by your response as my suggestion IS in VBA.
    >
    > --
    > Ian
    > --
    > "gti_jobert" <[email protected]> wrote
    > in message news:[email protected]...
    > >
    > > Hi again,
    > >
    > > Thanks for the promt reply! I have tried what you have suggested and
    > > works quite well. I'm not sure if it can be done in VBA, but is there a
    > > way of using an activex control to mask the textbox? I may have seen
    > > somewhere on the web that it can be done in VB6?!
    > >
    > > Does anyone know how to do it in VBA?
    > >
    > > Thanks Again!
    > >
    > >
    > > --
    > > gti_jobert
    > > ------------------------------------------------------------------------
    > > gti_jobert's Profile:
    > > http://www.excelforum.com/member.php...o&userid=30634
    > > View this thread: http://www.excelforum.com/showthread...hreadid=502886
    > >


    --

    Dave Peterson

  6. #6
    Ian
    Guest

    Re: Textbox Format

    Sorry, I didn't read the post properly.

    --
    Ian
    --
    "Dave Peterson" <[email protected]> wrote in message
    news:[email protected]...
    > gti_jobert wanted to know if he/she can mask the textbox so that the
    > format can
    > be "built-in".
    >
    > Excel's textboxes don't support this.
    >
    > Ian wrote:
    >>
    >> I'm confused by your response as my suggestion IS in VBA.
    >>
    >> --
    >> Ian
    >> --
    >> "gti_jobert" <[email protected]>
    >> wrote
    >> in message
    >> news:[email protected]...
    >> >
    >> > Hi again,
    >> >
    >> > Thanks for the promt reply! I have tried what you have suggested and
    >> > works quite well. I'm not sure if it can be done in VBA, but is there a
    >> > way of using an activex control to mask the textbox? I may have seen
    >> > somewhere on the web that it can be done in VB6?!
    >> >
    >> > Does anyone know how to do it in VBA?
    >> >
    >> > Thanks Again!
    >> >
    >> >
    >> > --
    >> > gti_jobert
    >> > ------------------------------------------------------------------------
    >> > gti_jobert's Profile:
    >> > http://www.excelforum.com/member.php...o&userid=30634
    >> > View this thread:
    >> > http://www.excelforum.com/showthread...hreadid=502886
    >> >

    >
    > --
    >
    > Dave Peterson




+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1