Answer the question
In order to leave comments, you need to log in
How to select focused element in VB.net?
I've only been doing VB.net for a couple of days and now I'm making a calculator.
So, I want that when you click on the button, let's say "1", in the TextBox on which the focus is, this number is entered.
Help with focus.
Answer the question
In order to leave comments, you need to log in
If I understand correctly, then:
'У формы ставишь свойство
KeyPreview = True
'На событие KeyUp
Private Sub Form1_KeyUp(sender As Object, e As KeyEventArgs) Handles MyBase.KeyUp
Select Case e.KeyCode
Case Keys.D1, Keys.NumPad1
TextBox1.Text &= 1
Case Keys.D2, Keys.NumPad2
TextBox1.Text &= 2
'...'
Case Keys.Back
If TextBox1.Text.Length > 0 Then TextBox1.Text = TextBox1.Text.Substring(0, TextBox1.Text.Length - 1)
End Select
End Sub
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question