+ Reply to Thread
Results 1 to 3 of 3

UserForm TextBoxes

Hybrid View

  1. #1
    Mangus Pyke
    Guest

    Re: UserForm TextBoxes

    On Thu, 28 Jul 2005 09:56:08 +0930, "Rob" <NA> wrote:
    >Some things I can't get right are:
    >I want to restrict the input to numbers only.


    I would use the WorksheetFunction ISNUMBER to check that the value is
    numeric.. you can use a sub-routine that runs upon exiting the field..

    Private Sub LoanTextBox_Exit(ByVal Cancel As MSForms.ReturnBoolean)
    If Application.WorksheetFunction.IsNumber(txtBox) Then
    Exit Sub
    Else
    MsgBox ("Sorry, please use only numbers")
    LoanTextBox.SetFocus
    End If
    End Sub

    Whenever someone leaves this text box, the sub-routine will check to
    see if the value is numeric. If it is, it exits the sub-routine.
    Otherwise, it gives them a message box that says they must use only
    numbers, and sets the focus back into the text box. If they try to
    leave again, it will do the same unless they changed their entry to
    numeric.

    >I want the TextBoxes to be blank and not show a "0" OR have it so that the 0
    >amount is highlighted so that when the user clicks in the box it overwrites
    >the 0. (When I use "" instead of 0 when resetting the Textboxes to blank I
    >get a type missmatch alert.)


    LoanTextBox.Value = "" 'Sets them to a null value (blank)

    You could also do a sub-routine like the one above to clear it when
    they click on it. Set your initial value to "0" and then use this:

    Private Sub LoanTextBox_GotFocus()
    LoanTextBox.Value = ""
    End Sub

    That will clear it when they tab to or click on the text box.

    MP-
    --
    "Learning is a behavior that results from consequences."
    B.F. Skinner

  2. #2
    Registered User
    Join Date
    08-05-2005
    Posts
    1
    Thanks Mangus. Sorry It took so long for my reply. It seems to have missed my Outlook Express and I had to go to the web to find your answer.

    Ihaven't had a chance to try it yet, but It looks good.

    Rob

+ 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