Dim FrenchMark As Integer = 0
    Dim GermanMark As Integer = 0
    Dim SpanishMark As Integer = 0
    Dim PercentageMark As Integer

    Private Sub Button1_Click(ByVal sender As Object, ByVal e As EventArgs) Handles Button1.Click

        EnterMarks()

    End Sub

    Private Sub EnterMarks()
        Try
            FrenchMark = InputBox("Please enter a whole number between 1 and 30", "Enter French mark...")
            If FrenchMark <= 1 Or FrenchMark >= 30 Then
                MessageBox.Show("Please enter a whole number between 1 and 30!")
                FrenchMark = 0
                Exit Sub
            End If
            GermanMark = InputBox("Please enter a whole number between 1 and 30", "Enter German mark...")
            If GermanMark <= 1 Or GermanMark >= 30 Then
                MessageBox.Show("Please enter a whole number between 1 and 30!")
                GermanMark = 0
                Exit Sub
            End If
            SpanishMark = InputBox("Please enter a whole number between 1 and 30", "Enter Spanish mark...")
            If SpanishMark <= 1 Or SpanishMark >= 30 Then
                MessageBox.Show("Please enter a whole number between 1 and 30!")
                SpanishMark = 0
                Exit Sub
            End If
        Catch ex As Exception
            MessageBox.Show("You can only enter numbers!")
            Exit Sub
        End Try

    End Sub

    Private Sub Button2_Click(ByVal sender As Object, ByVal e As EventArgs) Handles Button2.Click

        If FrenchMark = 0 Or GermanMark = 0 Or SpanishMark = 0 Then
            MessageBox.Show("Please enter your marks first!")
            Exit Sub
        End If


        ListBox1.Items.Add("French Mark:    " & FrenchMark)
        ListBox1.Items.Add("German Mark:    " & GermanMark)
        ListBox1.Items.Add("Spanish Mark:    " & SpanishMark)
        ListBox1.Items.Add("")

        PercentageMark = ((FrenchMark + GermanMark + SpanishMark) / 90) * 100

        If PercentageMark >= 50 Then
            ListBox1.Items.Add("You have passed.")
            ListBox1.Items.Add("Your percentage mark was " & PercentageMark)
        Else
            ListBox1.Items.Add("You have not passed.")
            ListBox1.Items.Add("Your percentage mark was " & PercentageMark)
        End If

    End Sub

Are you required to use InputBox? Not sure why you are using ListBox for those things.

  1. Prompt user for French marks (handle invalid entries)
  2. Prompt user for German marks (handle invalid entries)
  3. Prompt user for Spanish marks (handle invalid entries)
  4. Add marks to ListBox
  5. Calculate percentage mark
  6. Display result

Note: Re-check your calculation. Consider displaying your message using a Label, MessageBox, etc.

Consider using a ComboBox for each mark type and populate it with numbers 1-30.

Edited 2 Years Ago by cgeier

Comments
Hey, i was asked by a teacher to use a listbox, anyways is that the pseudocode then yea?

You start by writing comments and putting them in your code. The comments should say what the code does, not how it does it. Then you remove the code. What's left is your pseudocode.

Edited 2 Years Ago by Reverend Jim

This question has already been answered. Start a new discussion instead.