+ Reply to Thread
Results 1 to 5 of 5

Digits in textbox's

  1. #1
    Greg B
    Guest

    Digits in textbox's

    Hi all just wondering how I can get someone only to type number in a certain
    textbox?

    Thanks in advance

    Greg



  2. #2
    Vasant Nanavati
    Guest

    Re: Digits in textbox's

    Is this a TextBox on a UserForm?

    Somewhat crude, but try the following:

    Private Sub TextBox1_Change()
    If Not IsNumeric(TextBox1.Text) Then _
    SendKeys "{BACKSPACE}"
    End Sub

    --

    Vasant




    "Greg B" <laptopgb@ihug.com.au> wrote in message
    news:dff3gt$uti$1@lust.ihug.co.nz...
    > Hi all just wondering how I can get someone only to type number in a
    > certain
    > textbox?
    >
    > Thanks in advance
    >
    > Greg
    >
    >




  3. #3
    Greg B
    Guest

    Re: Digits in textbox's

    Thank you for that

    Greg
    "Vasant Nanavati" <vasantn AT aol DOT com> wrote in message
    news:#YvsfnWsFHA.1204@TK2MSFTNGP15.phx.gbl...
    > Is this a TextBox on a UserForm?
    >
    > Somewhat crude, but try the following:
    >
    > Private Sub TextBox1_Change()
    > If Not IsNumeric(TextBox1.Text) Then _
    > SendKeys "{BACKSPACE}"
    > End Sub
    >
    > --
    >
    > Vasant
    >
    >
    >
    >
    > "Greg B" <laptopgb@ihug.com.au> wrote in message
    > news:dff3gt$uti$1@lust.ihug.co.nz...
    > > Hi all just wondering how I can get someone only to type number in a
    > > certain
    > > textbox?
    > >
    > > Thanks in advance
    > >
    > > Greg
    > >
    > >

    >
    >




  4. #4
    Chip Pearson
    Guest

    Re: Digits in textbox's

    Better than SendKeys, use the KeyPress event.


    Private Sub TextBox1_KeyPress(ByVal KeyAscii As
    MSForms.ReturnInteger)
    If KeyAscii < 48 Or KeyAscii > 57 Then
    KeyAscii = 0
    End If
    End Sub



    --
    Cordially,
    Chip Pearson
    Microsoft MVP - Excel
    Pearson Software Consulting, LLC
    www.cpearson.com

    "Vasant Nanavati" <vasantn AT aol DOT com> wrote in message
    news:%23YvsfnWsFHA.1204@TK2MSFTNGP15.phx.gbl...
    > Is this a TextBox on a UserForm?
    >
    > Somewhat crude, but try the following:
    >
    > Private Sub TextBox1_Change()
    > If Not IsNumeric(TextBox1.Text) Then _
    > SendKeys "{BACKSPACE}"
    > End Sub
    >
    > --
    >
    > Vasant
    >
    >
    >
    >
    > "Greg B" <laptopgb@ihug.com.au> wrote in message
    > news:dff3gt$uti$1@lust.ihug.co.nz...
    >> Hi all just wondering how I can get someone only to type
    >> number in a certain
    >> textbox?
    >>
    >> Thanks in advance
    >>
    >> Greg
    >>
    >>

    >
    >




  5. #5
    Vasant Nanavati
    Guest

    Re: Digits in textbox's

    Hi Chip:

    I knew there was a better solution but just couldn't get my brain to come up
    with it <g>.

    Regards,

    Vasant

    "Chip Pearson" <chip@cpearson.com> wrote in message
    news:%23ddcZ4WsFHA.304@TK2MSFTNGP11.phx.gbl...
    > Better than SendKeys, use the KeyPress event.
    >
    >
    > Private Sub TextBox1_KeyPress(ByVal KeyAscii As MSForms.ReturnInteger)
    > If KeyAscii < 48 Or KeyAscii > 57 Then
    > KeyAscii = 0
    > End If
    > End Sub
    >
    >
    >
    > --
    > Cordially,
    > Chip Pearson
    > Microsoft MVP - Excel
    > Pearson Software Consulting, LLC
    > www.cpearson.com
    >
    > "Vasant Nanavati" <vasantn AT aol DOT com> wrote in message
    > news:%23YvsfnWsFHA.1204@TK2MSFTNGP15.phx.gbl...
    >> Is this a TextBox on a UserForm?
    >>
    >> Somewhat crude, but try the following:
    >>
    >> Private Sub TextBox1_Change()
    >> If Not IsNumeric(TextBox1.Text) Then _
    >> SendKeys "{BACKSPACE}"
    >> End Sub
    >>
    >> --
    >>
    >> Vasant
    >>
    >>
    >>
    >>
    >> "Greg B" <laptopgb@ihug.com.au> wrote in message
    >> news:dff3gt$uti$1@lust.ihug.co.nz...
    >>> Hi all just wondering how I can get someone only to type number in a
    >>> certain
    >>> textbox?
    >>>
    >>> Thanks in advance
    >>>
    >>> Greg
    >>>
    >>>

    >>
    >>

    >
    >




+ 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