BetaONE will rise again!


Reply
  #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
  #2  
Old 23rd Feb 03, 06:58 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
nevermind, this fixed it

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 100 To 90
           lblCGrade.Caption = "A"
       Case 79 To 89
           lblCGrade.Caption = "B"
       Case 69 To 78
           lblCGrade.Caption = "C"
       Case 59 To 68
           lblCGrade.Caption = "D"
       Case 0 To 58
           lblCGrade.Caption = "F"
   End Select

End Sub
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
unzipping question? SIRCOOKS Software Support 2 2nd Nov 04 03:00 PM
When posting a question User Needs Software Support 0 1st Nov 04 04:31 AM
For Dell and AMD, a tantalizing question NewsBot NeoWin News 0 26th Oct 04 03:30 PM
XP 64bit question volpe1564 Hardware Support 3 25th Mar 02 04:53 PM
Pentium Processor Question??? mayostudent Hardware Support 5 1st Oct 01 04:56 PM


All times are GMT +1. The time now is 04:31 PM.


Design by Vjacheslav Trushkin for phpBBStyles.com.
Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.