Hi all,

I have created a dialer in VB6 to dial a phone number. It have following buttons: the digits 0-9, backspace, "Call", and "Disconnect". Each one has separate command button associated with it. Now I want to enter numbers using the numpad of the keyboard. Keys are displayed in the text box. In the text box, any key can be typed in using the keypad. But I only want the number pad to operate.

For that I checked ASCII values using the KeyPress event for Text box checking if the pressed key value lies in between 47 and 58. But along with the key values its ASCII values are also getting displayed in the text box.

One more thing - I have one MS Flex Grid on the form along with the dialer. So when the cursor is on the form, or if the mouse is clicked anywhere other than the text box, values don't display in the text box. So how do I always keep focus on the text box? Here is the code

Code:
   Dim val As Integer

  Private Sub append(val As Integer)
  Text1.Text = Text1.Text & val
  End Sub   
  Private Sub Backspace_Click()
  With Text1
         'FOCUS TO THE TEXTBOX
         .SetFocus

         'PUT THE CURSOR AT THE END OF THE TEXT
         .SelStart = Len(.Text)

         'SEND THE KEY
         SendKeys ("{BACKSPACE}")

         'AND THATS IT :D
 End With
 End Sub

 Private Sub key_0_Click()
 val  = 0
 append val
 End Sub

 Private Sub key_1_Click()
 val = 1
 append val
 End Sub

 Private Sub key_2_Click()
 val = 2
 append val
 End Sub

 Private Sub key_3_Click()
 val = 3
 append val
 End Sub

 Private Sub key_4_Click()
 val = 4
 append val
 End Sub


 Private Sub key_5_Click()
 val = 5
 append val
 End Sub

 Private Sub key_6_Click()
 val = 6
 append val
 End Sub

 Private Sub key_7_Click()
 val = 7
 append val
 End Sub

 Private Sub key_8_Click()
 val = 8
 append val
 End Sub

 Private Sub key_9_Click()
 val = 9
 append val
 End Sub


 Private Sub Text1_KeyPress(KeyAscii As Integer)
 If (KeyAscii > 47 And KeyAscii < 58) Then
 val = KeyAscii
 append val
 Else
 KeyAscii = 0

' Text1.Text = KeyAscii End If End Sub

'Private Sub Text1_LostFocus()
' Text1.SetFocus
'End Sub