Results 1 to 7 of 7

Thread: [RESOLVED] urgent help needed

  1. #1

    Thread Starter
    New Member
    Join Date
    Apr 2006
    Posts
    6

    Resolved [RESOLVED] urgent help needed

    Hey guys,

    I want to make it so i can enter three exam subjects, then the mark of the exam and click a button to convert the mark into a grade e.g. A, B, C etc.

    If someone would be able to give me the code to link an exam subject text box to an exam mark text box and make it be converted into a grade by pressing a command button. That would be great, i just need it for one then i can use it for the others.

    mark boundaries are:

    0 to 39 grade U
    40 to 59 grade C
    60 to 79 grade B
    80 to 100 grade A


    I would really appreciate anyone who helps with this
    Last edited by VB_Crazy; Apr 22nd, 2006 at 05:23 AM.

  2. #2
    Frenzied Member litlewiki's Avatar
    Join Date
    Dec 2005
    Location
    Zeta Reticuli Distro:Ubuntu Fiesty
    Posts
    1,162

    Re: urgent help needed

    why dont use a select case structure to determine the range in which your total marks falls like
    Code:
    dim total_marks as integer
    total_marks = val(text1.text) + val(text2.text)
    select case total_marks
               case total_marks<39
               'code
               case total_marks >40 and total_marks < 59
               'code
    end select
    is this what u were asking for??
    __________________
    ________________0___
    ___0________(___)____
    __(___)_________) _/_____
    ___\_ (_________(_/______
    ____\_)_________________

  3. #3
    Frenzied Member litlewiki's Avatar
    Join Date
    Dec 2005
    Location
    Zeta Reticuli Distro:Ubuntu Fiesty
    Posts
    1,162

    Thumbs up Re: urgent help needed

    by the way welcome to vbf
    __________________
    ________________0___
    ___0________(___)____
    __(___)_________) _/_____
    ___\_ (_________(_/______
    ____\_)_________________

  4. #4

    Thread Starter
    New Member
    Join Date
    Apr 2006
    Posts
    6

    Re: urgent help needed

    that code didnt really do what i needed, i just need to be able to enter a subject and mark in seperate boxes and then press a button that pops up a message box with the converted using those grade boundaries..

    0 to 39 grade U
    40 to 59 grade C
    60 to 79 grade B
    80 to 100 grade A

    so if they get a mark within 0 to 39 they get a U for that subject e.g. maths.

  5. #5
    Hyperactive Member Bearnerd's Avatar
    Join Date
    Apr 2006
    Location
    Malaysia
    Posts
    290

    Re: urgent help needed

    Maybe this simple code will help to solve your answer.


    VB Code:
    1. Private Sub Command1_Click()
    2.     Dim Mark As Integer
    3.     Mark = Text1.Text
    4.  
    5.     If Mark <= 39 Then
    6.         MsgBox "You get U for the subject " & Combo1
    7.     ElseIf Mark >= 40 And Mark <= 59 Then
    8.         MsgBox "You get C for the subject " & Combo1
    9.     ElseIf Mark >= 60 And Mark <= 79 Then
    10.         MsgBox "You get B for the subject " & Combo1
    11.     ElseIf Mark >= 80 And Mark <= 100 Then
    12.         MsgBox "You get A for the subject " & Combo1
    13.     End If
    14. End Sub
    15.  
    16. Private Sub Form_Load()
    17.     Text1.Text = 100
    18.     Combo1 = "Physic"
    19.     Combo1.AddItem "Physic"
    20.     Combo1.AddItem "Math"
    21.     Combo1.AddItem "Science"
    22. End Sub

    Don't forget to add a combobox and textbox in your form. Dun 4get to rate

  6. #6
    Oi, fat-rag! bushmobile's Avatar
    Join Date
    Mar 2004
    Location
    on the poop deck
    Posts
    5,592

    Re: urgent help needed

    litlewiki has given you the basis of how to do it:

    VB Code:
    1. Dim sGrade As String
    2. Select Case Val(txtMark.Text)
    3.     Case Is < 40
    4.         sGrade = "U"
    5.     Case 40 To 59
    6.         sGrade = "C"    
    7.     Case 60 To 79
    8.         sGrade = "B"
    9.     Case Is >= 80
    10.         sGrade = "A"
    11. End Select
    If you want to average out marks, have different weightings etc, then you'll have to calculate that value before you decide the grade

  7. #7

    Thread Starter
    New Member
    Join Date
    Apr 2006
    Posts
    6

    Re: urgent help needed

    wow thanks Bearnerd it works how i want cheers

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