I need help in write this code. If someone can give me a hand on this please.

I need to determine which students have a specific major based upon the button that is clicked , then code will pull all the CS student's name and put them in the results list box. The text box above the results list box should contain the specified major and the text box below the results list box should contain a message indicating the total number of students with specific major.
Please the picture.

Thank you

Recommended Answers

All 4 Replies

Most of us have objections to doing your homework for you. We will help you with parts of it and give advice but only after you've shown us you've made some effort. Right now you're asking us to do your assignment for you. Show us what you've done.

Most of us have objections to doing your homework for you. We will help you with parts of it and give advice but only after you've shown us you've made some effort. Right now you're asking us to do your assignment for you. Show us what you've done.

Here is my first step toward the project. Any guide or hints to resolved this code please
Thank you.

Public Class frmHW12Toledo

    'lstStudents
    'lstMajors
    'lstResult

    'txtMajorName
    'txtMajorQty

    'btnCS
    'btnIT
    'btnLA

    ' Declare variables
    'Dim major As Integer
    Dim students As Integer
    ' Search CS
    Private Sub btnCS_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCS.Click
        For students = 1 To lstStudents
            lstStudents.Items.Add(lstResult.Text)
        Next
        txtMajorName.Text = "Computer Science"
        lstResult.Items.Clear()
    End Sub

    ' Search IT
    Private Sub btnIT_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnIT.Click
        txtMajorName.Text = "Information technology"
        lstResult.Items.Clear()
    End Sub

    ' Search LA
    Private Sub btnLA_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnLA.Click
        txtMajorName.Text = "Liberal Arts"
        lstResult.Items.Clear()
    End Sub
End Class

Here is my first step toward the project. Any guide or hints to resolved this code please
Thank you.

Public Class frmHW12Toledo

    'lstStudents
    'lstMajors
    'lstResult

    'txtMajorName
    'txtMajorQty

    'btnCS
    'btnIT
    'btnLA

    ' Declare variables
    'Dim major As Integer
    Dim students As Integer
    ' Search CS
    Private Sub btnCS_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCS.Click
        For students = 1 To lstStudents
            lstStudents.Items.Add(lstResult.Text)
        Next
        txtMajorName.Text = "Computer Science"
        lstResult.Items.Clear()
    End Sub

    ' Search IT
    Private Sub btnIT_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnIT.Click
        txtMajorName.Text = "Information technology"
        lstResult.Items.Clear()
    End Sub

    ' Search LA
    Private Sub btnLA_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnLA.Click
        txtMajorName.Text = "Liberal Arts"
        lstResult.Items.Clear()
    End Sub
End Class

Any one willing to help.
Thank you..

'lstStudents
    'lstMajors
    'lstResult

    'txtMajorName
    'txtMajorQty

    'btnCS
    'btnIT
    'btnLA

    ' Search CS
    Private Sub btnCS_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCS.Click
        Dim s As Integer = lstStudents.Items.Count
        For i As Integer = (s - 1) To (s - 10)
            lstResult.Items.Add(lstStudents.Items(i))
        Next
        txtMajorName.Text = "Computer Science"
        lstResult.Items.Clear()
    End Sub

    ' Search IT
    Private Sub btnIT_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnIT.Click
        ' Calculate the Majors
        Dim n As Integer = lstMajors.Items.Count
        Dim sum As Double = 0

        For i As Integer = 0 To n - 1
            sum += CDbl(lstMajors.Items(i))
        Next
        txtMajorQty.Text = "Number of Majors: " & FormatNumber(sum + n)

         txtMajorName.Text = "Information technology"
        lstResult.Items.Clear()
    End Sub

    ' Search LA
    Private Sub btnLA_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnLA.Click
        txtMajorName.Text = "Liberal Arts"
        lstResult.Items.Clear()
    End Sub
End Class

Any one willing to help.
Thank you..

'lstStudents
    'lstMajors
    'lstResult

    'txtMajorName
    'txtMajorQty

    'btnCS
    'btnIT
    'btnLA

    ' Search CS
    Private Sub btnCS_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCS.Click
        Dim s As Integer = lstStudents.Items.Count
        For i As Integer = (s - 1) To (s - 10)
            lstResult.Items.Add(lstStudents.Items(i))
        Next
        txtMajorName.Text = "Computer Science"
        lstResult.Items.Clear()
    End Sub

    ' Search IT
    Private Sub btnIT_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnIT.Click
        ' Calculate the Majors
        Dim n As Integer = lstMajors.Items.Count
        Dim sum As Double = 0

        For i As Integer = 0 To n - 1
            sum += CDbl(lstMajors.Items(i))
        Next
        txtMajorQty.Text = "Number of Majors: " & FormatNumber(sum + n)

         txtMajorName.Text = "Information technology"
        lstResult.Items.Clear()
    End Sub

    ' Search LA
    Private Sub btnLA_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnLA.Click
        txtMajorName.Text = "Liberal Arts"
        lstResult.Items.Clear()
    End Sub
End Class

Here is an update code of my work. If any one willing to give me any idea what aproach should I take to accomplished this project.
Thank you,

' Declare variables
    Dim major As String
    Dim nameMajor As String

    ' Search CS
    Private Sub btnCS_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCS.Click
        Dim s As Integer = lstStudents.Items.Count
        For i As Integer = (s - 1) To (s - 10)
            lstResult.Items.Add(lstStudents.Items(i))
        Next
        txtMajorName.Text = "Computer Science"
        lstResult.Items.Clear()
    End Sub

    ' Search IT
    Private Sub btnIT_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnIT.Click
        ' Calculate the Majors
        Dim n As Integer = lstMajors.Items.Count
        Dim sum As Double = 0

        For i As Integer = 0 To n - 1
            sum += CDbl(lstMajors.Items(i))
        Next
        txtMajorQty.Text = "Number of Majors: " & FormatNumber(sum + n)

         txtMajorName.Text = "Information technology"
        lstResult.Items.Clear()
    End Sub

    ' Search LA
    Private Sub btnLA_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnLA.Click
        Dim name As String
        For i As Integer = 0 To lstMajors.Items.Count - 1
            major = CStr(lstMajors.Items(i))
            If (major = "LA") Then
                name = CStr(lstStudents.Items(i))
                lstResult.Items.Add(name)
            End If
        Next
        txtMajorName.Text = "Liberal Arts"
        lstResult.Items.Clear()
    End Sub
End Class
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.