How to enable only numpad of laptop in VB6

Status
Not open for further replies.

djc

Advanced Member level 1
Joined
Jan 27, 2013
Messages
402
Helped
3
Reputation
6
Reaction score
2
Trophy points
1,298
Location
India
Visit site
Activity points
4,554
Hi all,

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
 

Hi,

This is the code,
Code:
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?
 

could you sense the MouseClick or MouseOver events on the other component and then display the text in the TextBox?
 

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.
 

[QUOTE/]could you sense the MouseClick or MouseOver events on the other component and then display the text in the TextBox?[/QUOTE]

I haven't written for mouse click event. However command buttons for the number are working fine.

- - - Updated - - -

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.
 
Last edited:

calling a buttons OnClick method will raise a Click event (in effect the same as clicking the button)
 

Got the solution for focusing issue on text box only.

Code:
Private Sub Text1_LostFocus()
  Text1.SetFocus
End Sub

No, it's not working. It doesn't let me press the command button on the form.
 
Last edited:

Got the solution for focusing issue on text box only.

Code:
Private Sub Text1_LostFocus()
  Text1.SetFocus
End Sub

No, it's not working. It doesn't let me press the command button on the form.

I would guess you have focus locked on the TextBox and it won't let you do anything else

you need to rethink what you are trying to do, e.g. when do you want focus on the TextBox ?
 

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.

Locked property of text box is false.
 

Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…