VB6 SendKeys problem
I am trying to create a button to enter "0" value into textbox.
Private Sub cmd0_Click()
PvCurPaidAmt.SetFocus
PvCurPaidAmt.SelStart = Len(PvCurPaidAmt) + 1
PvCurPaidAmt.SelText = "0"
End Sub
Now the problem is the I have to change textbox to pvcurenccy texbox provided by third party api, that does not support SelStart and SelText funct开发者_如何转开发ions, so I cannot use the code above.
I am trying to use SendKeys:
Private Sub cmd0_Click()
PvCurPaidAmt.SetFocus
SendKeys "0"
End Sub
Now the problem is it does not continue with the next cursor. I am trying to do what On-screen keyborard is doing. Please help. Thank you.
If I understand you correctly, when set focus to the PvCurPaidAmt control, you cannot be sure that the cursor will be at the end of the string (or that the whole string isn't selected or highlighted to begin with).
If the PvCurPaidAmt control has a .Text property, you could do:
PvCurPaidAmt.Text = PvCurPaidAmt.Text & "0"
If not, first SendKeys to send the cursor to the end:
SendKeys "{END}", True ' it will force the app to wait till the keys are processed
then
SendKeys "0"
精彩评论