How to Create a Local Polling System
Submitted by Yorkiebar on Sunday, September 22, 2013 - 14:08.
Language
Introduction:
Welcome to my tutorial on how to create a local polling system in a Visual Basic Application using its Project Settings.
Steps of Creation:
Step 1:
First we need to set our project settings. I have put "str1", "str2" and "str3" to contains the polling string options, "option1", "option2" and "option3" to contain the votes for each option and finally "question" to contain the question.
Step 2:
Now make the appropriate buttons and labels for your form. I have three options so I have put three buttons (one for each option to vote) and three labels (one for each current vote total). Also add a label to contain the question.
Step 3:
Now we are going to make a function to update our labels with the current vote total...
Step 4:
Now lets use that new function. On our form load event we want to set the question to the appropriate label and set the labels that contain the total votes for each option...
Step 5:
Finally lets add one to the appropriate option whenever a vote button is clicked and update the total vote counting labels...
Project Complete!
That's it! Below is the full source code and download to the project files.
- Private Function updateValues()
- Label1.Text = My.Settings.str1 & " Votes: " & My.Settings.Option1
- Label2.Text = My.Settings.str2 & " Votes: " & My.Settings.Option2
- Label3.Text = My.Settings.str3 & " Votes: " & My.Settings.Option3
- End Function
- Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
- updateValues()
- Label4.Text = My.Settings.question
- End Sub
- Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
- My.Settings.Option1 += 1
- updateValues()
- End Sub
- Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
- My.Settings.Option2 += 1
- updateValues()
- End Sub
- Private Sub Button3_Click(sender As Object, e As EventArgs) Handles Button3.Click
- My.Settings.Option3 += 1
- updateValues()
- End Sub
- Public Class Form1
- Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
- My.Settings.Option1 += 1
- updateValues()
- End Sub
- Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
- My.Settings.Option2 += 1
- updateValues()
- End Sub
- Private Sub Button3_Click(sender As Object, e As EventArgs) Handles Button3.Click
- My.Settings.Option3 += 1
- updateValues()
- End Sub
- Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
- updateValues()
- Label4.Text = My.Settings.question
- End Sub
- Private Function updateValues()
- Label1.Text = My.Settings.str1 & " Votes: " & My.Settings.Option1
- Label2.Text = My.Settings.str2 & " Votes: " & My.Settings.Option2
- Label3.Text = My.Settings.str3 & " Votes: " & My.Settings.Option3
- End Function
- End Class
Note: Due to the size or complexity of this submission, the author has submitted it as a .zip file to shorten your download time. After downloading it, you will need a program like Winzip to decompress it.
Virus note: All files are scanned once-a-day by SourceCodester.com for viruses, but new viruses come out every day, so no prevention program can catch 100% of them.
FOR YOUR OWN SAFETY, PLEASE:
1. Re-scan downloaded files using your personal virus checker before using it.
2. NEVER, EVER run compiled files (.exe's, .ocx's, .dll's etc.)--only run source code.
Add new comment
- 99 views