How to Create a Broken Keys Program in Visual Basic

Introduction: Welcome to my tutorial on how to create a Broken Keys program in Visual Basic. This program will allow a user with a bad keyboard to easily write a sentance and copy it to their clipboard, ready to paste in to other applications. Steps of Creation: Step 1: First lets create a form with; button1 - Add the current selection to the text to be copied button2 - Copy the text to the clipboard button3 - Go to the next character Button4 - Go to the previous character textbox1 - Contain the current text to be copied label1 - Contain the current character to be added. Lets also make a current position integer and a list ready to hold our characters.
  1. Dim curPos As Integer = 0
  2. Dim items As New List(Of String)
Step 2: Next we want to add our possible characters to our character list. We do this on form load so it is ready for us instantly.
  1. items.Add("A")
  2. items.Add("B")
  3. items.Add("C")
  4. items.Add("D")
  5. items.Add("E")
  6. items.Add("F")
  7. items.Add("G")
  8. items.Add("H")
  9. items.Add("I")
  10. items.Add("J")
  11. items.Add("K")
  12. items.Add("L")
  13. items.Add("M")
  14. items.Add("N")
  15. items.Add("O")
  16. items.Add("P")
  17. items.Add("Q")
  18. items.Add("R")
  19. items.Add("S")
  20. items.Add("T")
  21. items.Add("U")
  22. items.Add("V")
  23. items.Add("W")
  24. items.Add("X")
  25. items.Add("Y")
  26. items.Add("Z")
  27. items.Add("a")
  28. items.Add("b")
  29. items.Add("c")
  30. items.Add("d")
  31. items.Add("e")
  32. items.Add("f")
  33. items.Add("g")
  34. items.Add("h")
  35. items.Add("i")
  36. items.Add("j")
  37. items.Add("k")
  38. items.Add("l")
  39. items.Add("m")
  40. items.Add("n")
  41. items.Add("o")
  42. items.Add("p")
  43. items.Add("q")
  44. items.Add("r")
  45. items.Add("s")
  46. items.Add("t")
  47. items.Add("u")
  48. items.Add("v")
  49. items.Add("w")
  50. items.Add("x")
  51. items.Add("y")
  52. items.Add("z")
  53. items.Add("1")
  54. items.Add("2")
  55. items.Add("3")
  56. items.Add("4")
  57. items.Add("5")
  58. items.Add("6")
  59. items.Add("7")
  60. items.Add("8")
  61. items.Add("9")
  62. items.Add("0")
Step 3: The only custom function I have created is to update the label with the current position of characters.
  1. Private Function updateLabel()
  2. Label1.Text = items(curPos)
  3. End Function
Step 4: Finally, we want to make the button actions.
  1. Private Sub Button3_Click(sender As Object, e As EventArgs) Handles Button3.Click
  2. curPos += 1
  3. updateLabel()
  4. End Sub
  5.  
  6. Private Sub Button4_Click(sender As Object, e As EventArgs) Handles Button4.Click
  7. curPos -= 1
  8. updateLabel()
  9. End Sub
  10.  
  11. Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
  12. My.Computer.Clipboard.Clear()
  13. My.Computer.Clipboard.SetText(TextBox1.Text)
  14. End Sub
  15.  
  16. Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
  17. TextBox1.Text &= items(curPos)
  18. End Sub
Project Complete! Below is the full source code and download to the project files.
  1. Public Class Form1
  2. Dim curPos As Integer = 0
  3. Dim items As New List(Of String)
  4.  
  5. Private Sub Button3_Click(sender As Object, e As EventArgs) Handles Button3.Click
  6. curPos += 1
  7. updateLabel()
  8. End Sub
  9.  
  10. Private Sub Button4_Click(sender As Object, e As EventArgs) Handles Button4.Click
  11. curPos -= 1
  12. updateLabel()
  13. End Sub
  14.  
  15. Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
  16. My.Computer.Clipboard.Clear()
  17. My.Computer.Clipboard.SetText(TextBox1.Text)
  18. End Sub
  19.  
  20. Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
  21. TextBox1.Text &= items(curPos)
  22. End Sub
  23.  
  24. Private Function updateLabel()
  25. Label1.Text = items(curPos)
  26. End Function
  27.  
  28. Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
  29. items.Add("A")
  30. items.Add("B")
  31. items.Add("C")
  32. items.Add("D")
  33. items.Add("E")
  34. items.Add("F")
  35. items.Add("G")
  36. items.Add("H")
  37. items.Add("I")
  38. items.Add("J")
  39. items.Add("K")
  40. items.Add("L")
  41. items.Add("M")
  42. items.Add("N")
  43. items.Add("O")
  44. items.Add("P")
  45. items.Add("Q")
  46. items.Add("R")
  47. items.Add("S")
  48. items.Add("T")
  49. items.Add("U")
  50. items.Add("V")
  51. items.Add("W")
  52. items.Add("X")
  53. items.Add("Y")
  54. items.Add("Z")
  55. items.Add("a")
  56. items.Add("b")
  57. items.Add("c")
  58. items.Add("d")
  59. items.Add("e")
  60. items.Add("f")
  61. items.Add("g")
  62. items.Add("h")
  63. items.Add("i")
  64. items.Add("j")
  65. items.Add("k")
  66. items.Add("l")
  67. items.Add("m")
  68. items.Add("n")
  69. items.Add("o")
  70. items.Add("p")
  71. items.Add("q")
  72. items.Add("r")
  73. items.Add("s")
  74. items.Add("t")
  75. items.Add("u")
  76. items.Add("v")
  77. items.Add("w")
  78. items.Add("x")
  79. items.Add("y")
  80. items.Add("z")
  81. items.Add("1")
  82. items.Add("2")
  83. items.Add("3")
  84. items.Add("4")
  85. items.Add("5")
  86. items.Add("6")
  87. items.Add("7")
  88. items.Add("8")
  89. items.Add("9")
  90. items.Add("0")
  91. End Sub
  92. End Class

Add new comment