I have created a dialer in VB6 to dial the entered phone number. It has all the command buttons from 0-9, one backspace one call and one disconnect button. Now i want that number should be fed by laptop too. Now whole keypad is working. Means in text box any key can be typed in using keypad. I want only numpad to operate. How this can be done.
in the TextBox Keypress event handler read the key pressed, if it is 0-9 accept it if not remove the last character from the TextBox
or use a TextChanged event handler - if the text is invalid write valid text to the TextBox
Private Sub append(index As Integer)
Text1.Text = Text1.Text & index
End Sub
Private Sub Text1_KeyPress(KeyAscii As Integer)
If (KeyAscii > 47 And KeyAscii < 58) Then
index = KeyAscii 'index as integer variable
append index ' append is function
Else
KeyAscii = 0
'End If
End Sub
In this code, Ascii values of the key is also getting displayed. Means if i type 0 then 048 will be displayed. Moreover Setfocus is on Textbox. But i have Msflex grid component on form too. So when cursor is clicked on other component no values will be displayed in Textbox. What could be done for that?
The handler can be installed at different window hierarchy levels, behaviour will be respectively different.
I'm not familiar with VB (neither particularly interested in it). In native Windows API programming, you can filter and modify the messages that are passed to the default handler and e.g. arrive at the sub-windows. I guess, that's possible with VB, too.
In native Windows API programming, you can filter and modify the messages that are passed to the default handler and e.g. arrive at the sub-windows. I guess, that's possible with VB, too.
I am also not familiar with VB and windows API programming. SO not getting what you want to suggest. Is there any logic so that when number key is pressed so that i can link that with the particuar command button on the form. So when 1 is pressed on numpad it will be co relate with command button with 1 on it, and 1 will be displayed in text box. And when ENTER key is pressed CALL button wil be activated.
I want focus always on the text box, no issues with that. Cursor may be anywhere on the form, but values should be displayed on the text box. As i mentioned earlier, MS flex grid is also present on the form.