I am in the process of designing a scouting program.
I have the following code:
Private Sub teamnum_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles teamnum.KeyPress
Dim allowedChars As String = "0123456789"
If allowedChars.IndexOf(e.KeyChar) = -1 Then
' Invalid Character
e.Handled = True
But I would like to add the function of a backspace key.
You have to use the ascii character for backspace which is 8.
Dim allowedChars As String = “0123456789” + Chr(8)
The solution to this problem in DOS-mode Pascal was to read ASCII character 8. In C, you would use \b or \x08. See this table for a VB constant called “vbBack” that may work equivalently.
the constant vbBack will work as well.
Thanks for all the answers, I will release the the database and cooresponding programs as soon as they are finished.
Ran into another issue I have a checkedlistbox with 6 checkboxes and would like to put code in a clear button to uncheck all of the 6 checkboxes.
Two ways you can do it…
- If they are the only checkboxes on the form(or panel, etc):
For each ctl as Control in Me.Controls
If TypeOf ctl is Checkbox then CType(ctl, Checkbox).Checked = False
- If there are other controls you don’t want to mess with, you’ll need to just specify each checkbox by name, such as:
You want to try something like this. Place it in the ButtonUnchecked clicked sub.
For i As Integer = 0 To checklistbox1.Items.Count - 1
Ok I finally found it. After a day on Google, here’s the code:
Dim i As Integer
For i = 0 To Me.CheckedListBox1.CheckedIndices.Count - 1