Any help that anyone could offer would be greatly appreciated. As you can see in the following code I have not written any code using the select case function. I understand how to write the select case statement, but how do I tally up the "0,1,2" so that I get a total for the amount of votes.
Warren High Pseudocode
Save the selectedIndex of each vote and vbnewline, so the next vote will be written on a new line.
Display Code:
if fileexists
var = readalltext
newlineposition = using theindexof method starting from present position variable find the position of vbnewline. newlineposition = var.indexof(vbnewline,present position variable)
do until newlineposition = -1 'did not find newline, therefore end of file.
using the substring method, get each vote starting at the presentposition, and the number of characters will be the newlineposition minus the presentposition. The syntax for the substring is var.substring(starting position, number of characters)
using the Select case add the votes which will be a "0","1", or "2".
add 2 to the newlineposition to get the new present position of the vote
using the indexof method from above get the next vote
end loop
display results
vb
Option Explicit On
Option Strict On
Public Class MainForm
Private candidates() As String = {"Mark Stone", "Shelma Patel", "Sam Perez"}
Private Sub MainForm_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
For subscript As Integer = 0 To 2
Me.candidateListBox.Items.Add(candidates(subscript).ToString)
Next
End Sub
Private Sub exitButton_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles exitButton.Click
If MessageBox.Show("Are you sure you want to exit?", "Close", MessageBoxButtons.YesNo, MessageBoxIcon.Question) = Windows.Forms.DialogResult.Yes Then
Me.Close()
End If
End Sub
Private Sub saveVoteButton_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles saveVoteButton.Click
Dim file As String = "VoteTally"
Dim votes As String
votes = Me.candidateListBox.SelectedIndex.ToString
My.Computer.FileSystem.WriteAllText(file, votes & vbNewLine, True)
End Sub
Private Sub displayButton_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles displayButton.Click
Dim str As String
Dim endofLine As Integer
Dim newlinePosition As Integer
Dim tally As String
Dim totalVotes As Decimal
If My.Computer.FileSystem.FileExists("VoteTally") Then
str = My.Computer.FileSystem.ReadAllText("VoteTally")
endofLine = str.IndexOf(vbNewLine, newlinePosition)
Do Until endofLine = -1
tally = str.Substring(newlinePosition, endofLine - newlinePosition)
totalVotes += Convert.ToDecimal(tally)
Me.candidateListBox.Items.Add(tally)
newlinePosition = str.IndexOf(vbNewLine, newlinePosition)
Loop
Me.candidateListBox.Items.Add(totalVotes)
End If
End Sub
End Class
Mod Edit: Please use code tags when posting your code. Code tags are used like so =>

Thanks,
PsychoCoder