Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7441077
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T10:57:18+00:00 2026-05-29T10:57:18+00:00

The List Box has three candidates and a record Button. Every time the record

  • 0

The List Box has three candidates and a record Button. Every time the record button is hit I need it to add those button clicks for each candidate that is selected in the List Box. My code keeps counting all the clicks no matter which candidate I am selecting in the List Box. How can I differentiate between each selected item in the List Box.

Here is an image of how the application should look: https://i.stack.imgur.com/s7TSJ.jpg

Public Class Form1

    Private Sub exitButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles exitButton.Click
        Me.Close()
    End Sub

    Dim candidatevotes(2) As Integer
    Dim vote
    Dim total

    Private Sub MainForm_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Me.Load

        candListBox.Items.Add("Mark Stone")
        candListBox.Items.Add("Sheima Patel")
        candListBox.Items.Add("Sam Perez")
        candListBox.SelectedIndex = 0

    End Sub
    Private Sub recordButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles recordButton.Click

        candidatevotes(vote) = candListBox.SelectedIndex

        total += candidatevotes(vote)


        Dim outfile As IO.StreamWriter
        outfile = IO.File.AppendText("voteinfo.txt")
        outfile.WriteLine(Convert.ToString(candListBox.SelectedItem))
        outfile.Close()

    End Sub
    Private Sub displayButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles displayButton.Click


        Dim infile As IO.StreamReader

        If IO.File.Exists("voteinfo.txt") = True Then
            infile = IO.File.OpenText("voteinfo.txt")

            infile.Close()
        End If


        markLabel.Text = total.ToString
        sheimaLabel.Text = total.ToString
        samLabel.Text = total.ToString


    End Sub
End Class
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-29T10:57:19+00:00Added an answer on May 29, 2026 at 10:57 am
    candidatevotes(vote) = candListBox.SelectedIndex
    total += candidatevotes(vote)
    

    should be

    candidatevotes(candListBox.SelectedIndex) += 1
    

    and

    markLabel.Text = total.ToString
    sheimaLabel.Text = total.ToString
    samLabel.Text = total.ToString
    

    should be

    markLabel.Text = candidatevotes(0)
    sheimaLabel.Text = candidatevotes(1)
    samLabel.Text = candidatevotes(2)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

One user control is a list box where each item in the list has
I have a WPF application that has a list box of images. Right now
I’m tryin to make a list box that has a different image and text
So, I have the following design: List box Text box Push button When I
I'm using a wizard control, step 1 has a list box with a list
In Silverlight, I have a Vertical ListBox that has a Horizontal ListBox for each
this is my problem i,ve to create a dropdown list box from a table
Just some general formatting questions about return records to a list box on a
I have used a list box to display few dates. A string contains a
I have a list box that when an item is selected or deselected I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.