Results 1 to 5 of 5

Thread: [RESOLVED] Help textbox input error

Threaded View

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Dec 2011
    Posts
    17

    Resolved [RESOLVED] Help textbox input error

    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
    Last edited by langamer101; Dec 14th, 2011 at 06:46 AM.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width