Programming with Microsoft Visual Basic 2015 (MindTap Course List)
Programming with Microsoft Visual Basic 2015 (MindTap Course List)
7th Edition
ISBN: 9781285860268
Author: Diane Zak
Publisher: Cengage Learning
Expert Solution & Answer
Book Icon
Chapter 4.LC, Problem 1RQ
Program Description Answer

The text box’s “KeyPress” event occurs when pressing any key in the keyboard.

Hence, correct answer is option “D”.

Expert Solution & Answer
Check Mark

Explanation of Solution

The KeyPress event:

If a key is pressed within a control (i.e. the control has been focused), then the KeyPress event will occur.

  • The keyPress event procedure sends the pressed key’s character to the “e” parameter of the keyPress event.
    • The acceptance of pressing key has been handled by using the property “Handled”.

e.Handled

  • “Handled” property contains the Boolean values “True” or “False”.
  • If the “Handled” property of the control is “true”, then the control cancels the pressed keys.

  e.Handled = True

  • If the “Handled” property of the control is “false”, then the control accepts the pressed keys.

  e.Handled = False

Example:

The sub procedure “CancelKeys” allows the text boxes “txtCode” and “txtSales” to accept only the numbers and the backspace key.

Private Sub CancelKeys(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) _

Handles txtCode.KeyPress, txtSales.KeyPress

'Allows only numbers and the Backspace key in the 'text box

If (e.KeyChar < "0" OrElse e.KeyChar > "9") AndAlso e.KeyChar <> ControlChars.Back Then

    'Cancel the key

            e.Handled = True

        End If

    End Sub

The above example is used to accept only the numeric value keys and the backspace key.

Sample Output

Output:

Note: Here, it does not accept the keys other than the numeric and backspace key.

Enter “12” as code. Then, press backspace key to delete the 2.

Screenshot of “Bonus Calculator” form

Programming with Microsoft Visual Basic 2015 (MindTap Course List), Chapter 4.LC, Problem 1RQ , additional homework tip  1

The 2 will be deleted after pressing the backspace key.

Screenshot of “Bonus Calculator” form

Programming with Microsoft Visual Basic 2015 (MindTap Course List), Chapter 4.LC, Problem 1RQ , additional homework tip  2

Want to see more full solutions like this?

Subscribe now to access step-by-step solutions to millions of textbook problems written by subject matter experts!
Students have asked these similar questions
In the past, encryption and decryption were mostly done by substitution and permutation of letters in a text message. study those classic cryptographic schemes Then, develop an automatic cipher using Javascript  The cipher should be able to perform the following tasks: generate keys encrypt a given plaintext message with a key selected from the list of keys generated decrypt a given ciphertext message with a known cipher key
List reasons why teachers should and shouldn’t be replaced by computers? State your response in a descriptive context. Provide five references from the with internet with your answers.
The attached picture shows the RTCAPI memory mapped register which has the address 0x180. 1)  Program the MCU's registers so that     a) SIRC is the clock source     b) the clock is divided by 16K     c) the clock is enabled     d) load is enabled
Knowledge Booster
Background pattern image
Similar questions
SEE MORE QUESTIONS
Recommended textbooks for you
Text book image
Programming with Microsoft Visual Basic 2017
Computer Science
ISBN:9781337102124
Author:Diane Zak
Publisher:Cengage Learning
Text book image
Microsoft Visual C#
Computer Science
ISBN:9781337102100
Author:Joyce, Farrell.
Publisher:Cengage Learning,
Text book image
Programming Logic & Design Comprehensive
Computer Science
ISBN:9781337669405
Author:FARRELL
Publisher:Cengage
Text book image
EBK JAVA PROGRAMMING
Computer Science
ISBN:9781337671385
Author:FARRELL
Publisher:CENGAGE LEARNING - CONSIGNMENT
Text book image
COMPREHENSIVE MICROSOFT OFFICE 365 EXCE
Computer Science
ISBN:9780357392676
Author:FREUND, Steven
Publisher:CENGAGE L