when I compile and run my code then input or type a letter in txtCS_Change() I get an (run-time error "13": type mismatch)
I want to know how to create a msgbox if I input or type a letter in the texbtox
Code:Dim X As Double Dim b As Double Dim c As Double Dim d As Double Dim e As Double Dim a As Double Private Sub Command2_Click() End Sub Private Sub cmdCOMPUTE_Click() a = Val(txtCS.Text) b = Val(txtHLAB.Text) c = Val(txtLEC.Text) d = Val(txtME.Text) e = Val(txtQ.Text) X = (Val(a) + Val(b) + Val(c) + Val(d) + Val(e)) / 5 txtPG = X MsgBox " the periodic grade is " & X & "", vbInformation, "RESULT" End Sub Private Sub cmdRESET_Click() txtCS = "" txtHLAB = "" txtLEC = "" txtME = "" txtPG = "" txtQ = "" txtCS.SetFocus End Sub Private Sub txtCS_Change() If txtCS > 100 Then MsgBox "Grade is greater than 100, Pls re-enter", vbInformation, "ERROR" End If End Sub Private Sub txtHLAB_Change() If txtHLAB > 100 Then MsgBox "Grade is greater than 100, Pls re-enter", vbInformation, "ERROR" End If End Sub Private Sub txtLEC_Change() If txtLEC > 100 Then MsgBox "Grade is greater than 100, Pls re-enter", vbInformation, "ERROR" End If End Sub Private Sub txtME_Change() If txtME > 100 Then MsgBox "Grade is greater than 100, Pls re-enter", vbInformation, "ERROR" End If End Sub Private Sub txtQ_Change() If txtQ > 100 Then MsgBox "Grade is greater than 100, Pls re-enter", vbInformation, "ERROR" End If End Sub




Reply With Quote
