Barbara from
Mumbai sent us this email:
"Hello,
I just created a user-form to calculate the perks and total salary
package based on the entry of a basic salary. The form works fine but
when I run the form the command box to calculate the perks and package
is highlighted and I have to click in the textbox against the label
name to start my entries. How can I avoid this situation so thet the
cursor appears inside the textbox against the label name automatically?
Barbara"
This problem has two solutions and you can use any one you like. You
can watch the training video
below (15.2 MB) before diving into the macro code.
The macro code for the various controls is given below:
Private Sub CommandButton1_Click()
TextBox3 = TextBox2.Value * (60 / 100) + TextBox2.Value * (15 / 100)
TextBox4 = Val(TextBox3) + Val(TextBox2)
End Sub
Private Sub CommandButton2_Click()
TextBox1 = ""
TextBox2 = ""
TextBox3 = ""
TextBox4 = ""
End Sub
Private Sub CommandButton3_Click()
End
End Sub
Private Sub Label1_Click()
End Sub
Private Sub UserForm_Activate()
TextBox1.SetFocus
End Sub