แก้ Checkbox กดแล้วหาย รันปุ่ม CommandBotton ไม่ได้ครับ รบกวนด้วยครับ
Posted: Sat Jun 13, 2015 1:22 pm
Code: Select all
Private Sub CheckBox1_Click()
If CheckBox1.Value Then
A = 66
Weight = 13.7
Height = 5
Old = 6.8
End If
Sheet1.Cells(2, 3) = CheckBox1.Caption
End Sub
Private Sub CheckBox2_Click()
Sheet1.Cells(2, 3) = CheckBox2.Caption
If CheckBox2.Value Then
A = 66.5
Weight = 9.6
Height = 1.8
Old = 4.7
End If
End Sub
Private Sub CommandButton1_Click()
Dim A As Double
Dim Weight As Double
Dim Height As Double
Dim Old As Double
Dim Weight2 As Double
Dim Height2 As Double
Dim Old As Double
Dim BMR As Double
Weight2 = Weight + TextBox1.Value
Height2 = Height + TextBox2.Value
Old2 = Old + TextBox3.Value
BMR = A + Weight2 + Height2 + Old2 * Work
TextBox4.Value = BMR
End Sub
Private Sub OptionButton1_Click()
End Sub
Private Sub OptionButton3_Click()
Dim Work As Single
Work = 1.2
Sheet1.Cells(6, 3) = OptionButton3.Caption
End Sub
Private Sub OptionButton4_Click()
Dim Work As Single
Work = 1.55
Sheet1.Cells(6, 3) = OptionButton4.Caption
End Sub
Private Sub OptionButton5_Click()
Dim Work As Single
Work = 1.99
Sheet1.Cells(6, 3) = OptionButton5.Caption
End Sub
Private Sub TextBox1_Change()
Sheet1.Cells(3, 3) = TextBox1.Value
If TextBox1.Value = "" Then
MsgBox " กรุณาใส่ตัวเลข "
End If
End Sub
Private Sub TextBox2_Change()
Sheet1.Cells(4, 3) = TextBox2.Value
If TextBox2.Value = "" Then
MsgBox " กรุณาใส่ตัวเลข "
End If
End Sub
Private Sub TextBox3_Change()
Sheet1.Cells(5, 3) = TextBox3.Value
If TextBox3.Value = "" Then
MsgBox " กรุณาใส่ตัวเลข "
End If
End Sub
Private Sub TextBox4_Change()
End Sub
Private Sub UserForm_Click()
MsgBox ("I love you.")
End Subเป็น code ที่เขียนใน vba ครับ สูตรเผาผลาญพลังงาน แต่รันไม่ได้ครับ แล้ว กด check box ก็หายไปอีก