Advertisement
Guest User

Untitled

a guest
Mar 27th, 2015
223
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.93 KB | None | 0 0
  1. Public Shared Sub AddNewButton()
  2.  
  3. Dim buttonTop As Integer = 100
  4.  
  5. For Each item As String In Globals.candidates
  6. Dim btn As New System.Windows.Forms.Button()
  7. Dim Location As New Point(100, (buttonTop + 20))
  8. btn.Location = Location
  9. btn.Text = item
  10. btn.Width = 150
  11. AddHandler btn.Click, AddressOf BallotCasting.buttonClick
  12. AddHandler btn.Tag, AddressOf ElectionResults.AddVotes
  13. BallotCasting.Controls.Add(btn)
  14. buttonTop += 20
  15. btn.Tag = 0
  16. Next
  17.  
  18. Public Sub buttonClick(sender As Object, e As EventArgs)
  19.  
  20. Dim btn As Button = DirectCast(sender, System.Windows.Forms.Button)
  21. Dim result As Integer = MessageBox.Show(String.Format("Did you select {0} ?", btn.Text), "Confirmation", MessageBoxButtons.YesNo)
  22.  
  23. If result = DialogResult.Yes Then
  24. btn.Tag += 1
  25. TextBox1.Text = btn.Tag
  26. Me.Hide()
  27. ElectionResults.Show()
  28. End If
  29.  
  30. End Sub
  31.  
  32. Public Sub AddCandidates()
  33.  
  34. Dim labelTop As Integer = 100
  35.  
  36. For Each item As String In Globals.candidates
  37. Dim canLabel As New System.Windows.Forms.Label()
  38. Dim Location As New Point(100, (labelTop + 20))
  39. canLabel.Location = Location
  40. canLabel.Text = item
  41. canLabel.Width = 50
  42. Me.Controls.Add(canLabel)
  43. labelTop += 20
  44. Next
  45.  
  46. End Sub
  47.  
  48. Public Sub AddVotes()
  49.  
  50. Dim voteTop As Integer = 100
  51.  
  52. For Each item As String In Globals.candidates
  53. Dim voteLabel As New System.Windows.Forms.Label()
  54. Dim Location As New Point(200, (voteTop + 20))
  55. voteLabel.Location = Location
  56. voteLabel.Text = ????? <------I want to use btn.tag but cannot.
  57. voteLabel.Width = 100
  58. Me.Controls.Add(voteLabel)
  59. voteTop += 20
  60. Next
  61.  
  62. End Sub
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement