Public Class Form1
' TODO
' try to figure out how to stop the checkChanged event from
' running at program startup. I could try putting the
' initial setup in FormLoad and then using a global flag to
' indicate if the redraw should happen. e.g. Dim AllowRedraw as boolean = false
' and change it to false when form_load finishes - but this is too early
' what event fires when the load is totally finished?
Private Sub redraw()
Dim colNo = 0
Label1.Text = ""
For i As Integer = 0 To 127
If i < 32 Or i = 127 Then
If Not Me.cbNonPrintable.Checked Then
Continue For
End If
Else
If Not Me.cbPrintable.Checked Then
Continue For
End If
End If
Label1.Text &= i.ToString() & " " & getDisplayInfo(i)
colNo += 1
If colNo = Val(tbNumCols.Text) Then
Label1.Text &= vbCrLf
Else
Label1.Text &= vbTab & vbTab
End If
Next
End Sub
Private Function getDisplayInfo(ByVal val As Integer) As String
If val >= 32 And val <= 126 Then
getDisplayInfo = Chr(val)
Else
getDisplayInfo = ""
If Me.cbAcronyms.Checked Then
getDisplayInfo &= " " & getAcronym(val)
End If
If Me.cbCtrlChars.Checked Then
getDisplayInfo &= " " & getCtrlChar(val)
End If
If Me.cbDescriptive.Checked Then
getDisplayInfo &= " " & getDescription(val)
End If
End If
End Function
Private Function getCtrlChar(ByVal i As Integer)
Return ""
End Function
Private Function getDescription(ByVal i As Integer)
Return ""
End Function
Private Function getAcronym(ByVal i As Integer)
Select Case i
Case 0
Return "NUL"
Case 1
Return "SOH"
Case 2
Return "STX"
Case 3
Return "ETX"
Case 4
Return "EOT"
Case 5
Return "ENQ"
Case 6
Return "ACQ"
Case 7
Return "BEL"
Case 8
Return "BS"
Case 9
Return "HT"
Case 10
Return "LF"
Case 11
Return "VT"
Case 12
Return "FF"
Case 13
Return "CR"
Case 14
Return "SO"
Case 15
Return "SI"
Case 16
Return "DLE"
Case 17
Return "DC1"
Case 18
Return "DC2"
Case 19
Return "DC3"
Case 20
Return "DC4"
Case 21
Return "NAK"
Case 22
Return "SYN"
Case 23
Return "ETB"
Case 24
Return "CAN"
Case 25
Return "EM"
Case 26
Return "SUB"
Case 27
Return "ESC"
Case 28
Return "FS"
Case 29
Return "GX"
Case 30
Return "RX"
Case 31
Return "US"
Case 32
Return "SPACE"
Case 127
Return "DEL"
Case Else
Return ""
End Select
End Function
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
redraw()
End Sub
Private Sub tbNumCols_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles tbNumCols.KeyPress
Select Case Asc(e.KeyChar)
Case 8, 48 To 57 ' all chars from 0 to 9 and backspace
e.Handled = False
Case Else
e.Handled = True
End Select
End Sub
Private Sub tbNumCols_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles tbNumCols.TextChanged
redraw()
End Sub
Private Sub cbNonPrintable_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cbNonPrintable.CheckedChanged
Me.gbNonPrintable.Enabled = Me.cbNonPrintable.Checked
redraw()
End Sub
Private Sub cheksChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cbDescriptive.CheckedChanged, cbAcronyms.CheckedChanged, cbCtrlChars.CheckedChanged, cbPrintable.CheckedChanged
redraw()
End Sub
End Class