none
Why do I have to click twice? Visual Basic 6 RRS feed

  • Question

  • Hi,

    Im confused, why I have to click twice to have the correct result on my program's equi and remarks txt box. I can only get correct display when i click the calculate grade button twice.

    please let me know why this happening and how to resolve the code. below is my code

    Private Sub cmdcalculate_Click()
    Dim q1 As Double, q2 As Double, q3 As Double, ass1 As Double, ass2 As Double, sw1 As Double, sw2 As Double, exam As Double, grade As Double, equi As Double
    Dim remarks As String
    remarks = txtremarks.Text
    q1 = Val(txtq1.Text)
    q2 = Val(txtq2.Text)
    q3 = Val(txtq3.Text)
    ass1 = Val(txtass1.Text)
    ass2 = Val(txtass2.Text)
    sw1 = Val(txtsw1.Text)
    sw2 = Val(txtsw2.Text)
    exam = Val(txtexam.Text)
    grade = Val(txtgrade.Text)
    equi = Val(txtequi.Text)
    txtgrade.Text = (((q1 + q2 + q3) / 3) * 0.3) + (((ass1 + ass2) / 2) * 0.2) + (((sw1 + sw2) / 2) * 0.2) + (exam * 0.3)
    Select Case grade
    Case grade >= 97 And grade <= 100
    txtequi.Text = "1.00"
    Case 93 To 96
    txtequi.Text = "1.25"
    Case 89 To 92
    txtequi.Text = "1.50"
    Case 85 To 88
    txtequi.Text = "1.75"
    Case 81 To 84
    txtequi.Text = "2.00"
    Case 77 To 80
    txtequi.Text = "2.25"
    Case 75 To 76
    txtequi.Text = "2.50"
    Case 72 To 74
    txtequi.Text = "2.75"
    Case 70 To 71
    txtequi.Text = "3.00"
    Case 65 To 69
    txtequi.Text = "4.00"
    Case grade >= 0 And grade <= 64
    txtequi.Text = "5.00"
    End Select
    Select Case grade
    Case grade >= 97 And grade <= 100
    txtremarks.Text = "Extra Ordinary"
    Case 93 To 96
    txtremarks.Text = "Excellent"
    Case 89 To 92
    txtremarks.Text = "Very Good"
    Case 85 To 88
    txtremarks.Text = "Good"
    Case 81 To 84
    txtremarks.Text = "Very Satisfactory"
    Case 77 To 80
    txtremarks.Text = "Satisfactory"
    Case 75 To 76
    txtremarks.Text = "Fair"
    Case 72 To 74
    txtremarks.Text = "Passing Level"
    Case 70 To 71
    txtremarks.Text = "Poor Yet Passing Level"
    Case 65 To 69
    txtremarks.Text = "Conditional Failure"
    Case grade >= 0 And grade <= 64
    txtremarks.Text = "Failed"
    End Select
    End Sub

    Thank you in advance...

    Bart

    Thursday, December 27, 2018 3:26 PM

Answers

  • Im sorry for this Karen..

    And thank you for directing me on the right forum link..

    • Marked as answer by Bartolome38 Thursday, December 27, 2018 5:25 PM
    Thursday, December 27, 2018 5:23 PM

All replies

  • Hello,

    When posting this question there was a notice indicating this forum is not for VB6 and there are no Microsoft forums for VB6.

    Please use the following http://www.vbforums.com/forumdisplay.php?1-Visual-Basic-6-and-Earlier


    Please remember to mark the replies as answers if they help and unmark them if they provide no help, this will help others who are looking for solutions to the same or similar problem. Contact via my Twitter (Karen Payne) or Facebook (Karen Payne) via my MSDN profile but will not answer coding question on either.
    VB Forums - moderator
    profile for Karen Payne on Stack Exchange, a network of free, community-driven Q&A sites

    Thursday, December 27, 2018 4:08 PM
    Moderator
  • Im sorry for this Karen..

    And thank you for directing me on the right forum link..

    • Marked as answer by Bartolome38 Thursday, December 27, 2018 5:25 PM
    Thursday, December 27, 2018 5:23 PM