Thread: VB6 Question...
View Single Post
  #1  
Old 23rd Feb 03, 06:47 PM
Sephiroth Sephiroth is offline
BetaONE Supporter
 
Join Date: Jul 2001
Posts: 1,979
Sephiroth is an unknown quantity at this point
Send a message via MSN to Sephiroth
I'm not sure if anybody here is good in VB or not other than Lucky who I dunno if will be on today or Zone-MR who is on vacation, but if so, can anybody tell me what I'm doing wrong in this bit of code?

Quote:

Private Sub cmdCalculate_Click()
   
   If txtName.Text = "" Then
       MsgBox "Please enter a student name."
   End If
   
   If ValidGrade(txtT1.Text) = False Then
       MsgBox "Please enter a number between 0 and 100 into Test 1."
   End If
   
   If ValidGrade(txtT2.Text) = False Then
       MsgBox "Please enter a number between 0 and 100 into Test 2."
   End If
   
   If ValidGrade(txtT3.Text) = False Then
       MsgBox "Please enter a number between 0 and 100 into Test 3."
   End If
   
   Dim pstrCGrade As Integer
   pstrCGrade = (Val(txtT1.Text) + Val(txtT2.Text) + Val(txtT3.Text)) / 3
   
   Select Case pstrCGrade
       Case "pstrCGrade = 100 To 90"
           MsgBox "Test A"
       Case "pstrCGrade = 79 To 89"
           MsgBox "Test B"
       Case "pstrCGrade = 69 To 78"
           MsgBox "Test C"
       Case "pstrCGrade = 59 To 68"
           MsgBox "Test D"
       Case "pstrCGrade = 0 To 58"
           MsgBox "Test F"
   End Select

End Sub
You enter a numeric into 3 text boxes... it tests they are numbers, and computes an average, that part works, but then the select case statement is what i'm having problems with.... it either gives me a type mismatch error or just doesn't do anything
Reply With Quote