Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Public Shared Sub AddNewButton()
- Dim buttonTop As Integer = 100
- For Each item As String In Globals.candidates
- Dim btn As New System.Windows.Forms.Button()
- Dim Location As New Point(100, (buttonTop + 20))
- btn.Location = Location
- btn.Text = item
- btn.Width = 150
- AddHandler btn.Click, AddressOf BallotCasting.buttonClick
- AddHandler btn.Tag, AddressOf ElectionResults.AddVotes
- BallotCasting.Controls.Add(btn)
- buttonTop += 20
- btn.Tag = 0
- Next
- Public Sub buttonClick(sender As Object, e As EventArgs)
- Dim btn As Button = DirectCast(sender, System.Windows.Forms.Button)
- Dim result As Integer = MessageBox.Show(String.Format("Did you select {0} ?", btn.Text), "Confirmation", MessageBoxButtons.YesNo)
- If result = DialogResult.Yes Then
- btn.Tag += 1
- TextBox1.Text = btn.Tag
- Me.Hide()
- ElectionResults.Show()
- End If
- End Sub
- Public Sub AddCandidates()
- Dim labelTop As Integer = 100
- For Each item As String In Globals.candidates
- Dim canLabel As New System.Windows.Forms.Label()
- Dim Location As New Point(100, (labelTop + 20))
- canLabel.Location = Location
- canLabel.Text = item
- canLabel.Width = 50
- Me.Controls.Add(canLabel)
- labelTop += 20
- Next
- End Sub
- Public Sub AddVotes()
- Dim voteTop As Integer = 100
- For Each item As String In Globals.candidates
- Dim voteLabel As New System.Windows.Forms.Label()
- Dim Location As New Point(200, (voteTop + 20))
- voteLabel.Location = Location
- voteLabel.Text = ????? <------I want to use btn.tag but cannot.
- voteLabel.Width = 100
- Me.Controls.Add(voteLabel)
- voteTop += 20
- Next
- End Sub
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement