+ Reply to Thread
Results 1 to 3 of 3

Keypress event???? data validation on a userform in vba for spread

  1. #1
    Roundy
    Guest

    Keypress event???? data validation on a userform in vba for spread

    I have a vba form I am using to have a user enter information into a
    spreadsheet to do some calculations for me. One of the values is a length
    value i.e. 164 and 3/8". What I am trying to accomplish is to have the user
    not be able to enter a " mark in the textbox, because that value in my
    spreadsheet breaks all of my formulas. My formulas just want a number, not
    "text". The control I am using for them to enter into is a text box.
    Someone said I should capture the kepress event and block it if it as a
    quotation mark before writing the value to the field. So...I am struggling
    with how to get this accomplished. Any help would be appreciated.

  2. #2
    Doug Glancy
    Guest

    Re: Keypress event???? data validation on a userform in vba for spread

    Roundy,

    I think this would work. I added the message to to reduce user
    confusion/frustration:

    Private Sub TextBox1_KeyPress(ByVal KeyAscii As MSForms.ReturnInteger)
    If KeyAscii = 34 Then
    MsgBox "Sorry, no quotes (" & Chr(34) & ") allowed."
    KeyAscii = 0
    End If
    End Sub

    hth,

    Doug


    "Roundy" <[email protected]> wrote in message
    news:[email protected]...
    >I have a vba form I am using to have a user enter information into a
    > spreadsheet to do some calculations for me. One of the values is a length
    > value i.e. 164 and 3/8". What I am trying to accomplish is to have the
    > user
    > not be able to enter a " mark in the textbox, because that value in my
    > spreadsheet breaks all of my formulas. My formulas just want a number,
    > not
    > "text". The control I am using for them to enter into is a text box.
    > Someone said I should capture the kepress event and block it if it as a
    > quotation mark before writing the value to the field. So...I am
    > struggling
    > with how to get this accomplished. Any help would be appreciated.




  3. #3
    Roundy
    Guest

    Re: Keypress event???? data validation on a userform in vba for sp

    Thank you so much for your response, it works great.

    "Doug Glancy" wrote:

    > Roundy,
    >
    > I think this would work. I added the message to to reduce user
    > confusion/frustration:
    >
    > Private Sub TextBox1_KeyPress(ByVal KeyAscii As MSForms.ReturnInteger)
    > If KeyAscii = 34 Then
    > MsgBox "Sorry, no quotes (" & Chr(34) & ") allowed."
    > KeyAscii = 0
    > End If
    > End Sub
    >
    > hth,
    >
    > Doug
    >
    >
    > "Roundy" <[email protected]> wrote in message
    > news:[email protected]...
    > >I have a vba form I am using to have a user enter information into a
    > > spreadsheet to do some calculations for me. One of the values is a length
    > > value i.e. 164 and 3/8". What I am trying to accomplish is to have the
    > > user
    > > not be able to enter a " mark in the textbox, because that value in my
    > > spreadsheet breaks all of my formulas. My formulas just want a number,
    > > not
    > > "text". The control I am using for them to enter into is a text box.
    > > Someone said I should capture the kepress event and block it if it as a
    > > quotation mark before writing the value to the field. So...I am
    > > struggling
    > > with how to get this accomplished. Any help would be appreciated.

    >
    >
    >


+ 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