VISUAL BASIC 1. Type the following lines of code at the very top of your code: O
ID: 672729 • Letter: V
Question
VISUAL BASIC
1. Type the following lines of code at the very top of your code:
Option Strict On
Option Infer Off
Option Explicit On
2. An employee will receive a $1,000 bonus if he/she has been with the company for 5 years or more and sold $100,000 or more.
3. Make a KeyPress event for the sales textbox. Only allow a user to type the numbers 0 through 9 and a backspace. Anything other characters being typed should just result with nothing happening.
4. Allow the user to type whatever they want in the years textbox. However, when the user clicks the submit button they should get the message shown below. This should be done by using an If statement.
Please help. I am having a lot of touble trying to figure this out...
Explanation / Answer
1.
Option Strict On
Option Infer Off
Option Explicit On
Public Class Form1
Private Sub key_press(ByVal sender As System.Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TextBox1.KeyPress
End Sub
Private Sub TextBox1_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox1.TextChanged
End Sub
Private Sub key_presss(ByVal sender As System.Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TextBox2.KeyPress
End Sub
End Class
2.
Option Strict On
Option Infer Off
Option Explicit On
Public Class Form1
Private Sub key_press(ByVal sender As System.Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TextBox1.KeyPress
End Sub
Private Sub TextBox1_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox1.TextChanged
End Sub
Private Sub key_presss(ByVal sender As System.Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TextBox2.KeyPress
If Val(TextBox1.Text) >= 5 And Val(TextBox2.Text) > 100000 Then
MsgBox("Bonus is $1000")
End If
End Sub
End Class
3.
Option Strict On
Option Infer Off
Option Explicit On
Public Class Form1
Private Sub key_press(ByVal sender As System.Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TextBox1.KeyPress
End Sub
Private Sub TextBox1_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox1.TextChanged
End Sub
Private Sub key_presss(ByVal sender As System.Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TextBox2.KeyPress
If Val(TextBox1.Text) < 0 And Val(TextBox1.Text) > 9 Then
MsgBox("Pl. enter 0-9 only")
TextBox2.Text = ""
End If
End Sub
Private Sub TextBox2_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox2.TextChanged
End Sub
End Class
4.
Option Strict On
Option Infer Off
Option Explicit On
Public Class Form1
Private Sub key_press(ByVal sender As System.Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TextBox1.KeyPress
End Sub
Private Sub TextBox1_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox1.TextChanged
End Sub
Private Sub TextBox2_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox2.TextChanged
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
If IsNumeric(Val(TextBox1.Text)) Then
Else
MsgBox(""please enter a valid number"")
End If
End Sub
End Class
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.