Hello,

I'm a real beginner and try to learn Visual Basic.
I have to code a marking assistant as illustrated in the attached picture.
I chose to use a listView to display the information typed by the user.
I succeeded to display the information in three first columns, but I have a problem with the fourth one. I don't know how to convert the information contained in the third column to a grade in the fourth one.
I really need some help.
Thank you in advance for your advices
Below my codes

Option Explicit On
Option Strict On
Option Infer Off

Public Class Form1
    Dim strFirstName As String
    Dim strLastName As String
    Dim intScore As Integer
    Dim intPossibleMarks As Integer
    Dim dblPercentage As Double
    Dim strMark As String
    Dim strGrade As String
    Dim intListViewDisplay As Integer
    
    Private Sub btnRecordStudent_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnRecordStudent.Click

        'Declare a variable to store the list index
        Dim intListViewDisplay As Integer
        'Display the FirstName in the FirstName colomn
        ListViewDisplay.Items.Add(txtFisrtName.Text)
        'DisplayRectangle the LastName in LastName colomn
        ListViewDisplay.Items(intListViewDisplay).SubItems.Add(txtLastName.Text)
        'Display the gender in the Gender colomn
        If RadioButtonMale.Checked = True Then
            ListViewDisplay.Items(intListViewDisplay).SubItems.Add("(M)")
        ElseIf RadioButtonFemale.Checked Then
            ListViewDisplay.Items(intListViewDisplay).SubItems.Add("(F)")
        End If
        'Display the marks in the Marks colomn
        strMark = txtScore.Text & "/" & txtPossibleMarks.Text
        ListViewDisplay.Items(intListViewDisplay).SubItems.Add(strMark)
        'Display the Grade in the Grade colomn
        Dim intGrade As Integer
        intGrade = intScore + intPossibleMarks * 100
        intGrade.ToString()
        ListViewDisplay.Items(intListViewDisplay).SubItems.Add(strGrade)
    End Sub
End Class

line 34 should be

intGrade = intScore/intPossibleMarks*100

that will give you a score as a percentage then you will need a select case statement to assign a letter to the score. something like

SELECT CASE TRUE
   CASE intGrade > 85
        strGrade = "A"
   CASE intGrade >75
        strGrade = "B"
   CASE ELSE
        strGrade = "E"
END SELECT
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.