title: How can i make a sub for a keypress event?
body: <p>I'm working on an excel with macros. I have a userform with textboxes, several of them use a function for only press numbers.</p>
  
  <p><a href="https://i.stack.imgur.com/j0wZi.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/j0wZi.png" alt="Example of UserForm"></a></p>
  
  <pre><code>Private Sub quantity1_KeyPress(ByVal KeyAscii As MSForms.ReturnInteger)
      Select Case KeyAscii
          Case Asc("0") To Asc("9")
          Case Else
          KeyAscii = 0
      End Select
  End Sub
  </code></pre>
  
  <p>How can i put the select case on a procedure or function
  and then call it from any keypress event that i need it (in this case, quantity1 quantity2, price1 and price2, but no in buyer)?
  I tried making a sub that uses the same parameters like the event e.g:</p>
  
  <pre><code>Sub Only_Numbers(ByVal KeyAscii As MSForms.ReturnInteger)
  </code></pre>