Mackeral
Board Regular
- Joined
- Mar 7, 2015
- Messages
- 249
- Office Version
- 365
- Platform
- Windows
These are 3 routines I've developed for debugging Ascii strings.
They all are executed in the Immediate Windows with a "?" call to display their results.
Display a string by showing character numbers:
This routine displays character values in more meanful ways:
This function compares two strings:
They all are executed in the Immediate Windows with a "?" call to display their results.
Display a string by showing character numbers:
VBA Code:
Function Ascii(ByVal Line)
'Display "Line" seperated by "," in chucnks.
' 4/29/21 Created. WML
Display = 60 ' Characters
Do
Char = Ascii_Display(Left(Line, 1))
Line = Mid(Line, 2)
If Len(Assembly & Char) > Display Then
Ascii = Ascii & Assembly & vbCr
Assembly = ""
End If
If Assembly = "" Then
Assembly = Assembly & Char
Else
Assembly = Assembly & "," & Char
End If
Loop Until Line = ""
Ascii = Ascii & Assembly
End Function ' Ascii
This routine displays character values in more meanful ways:
VBA Code:
Function Ascii_Display(Char)
' Convert "Char" into Ascii representation.
' 5/13/19 Created. WML
' 4/6/21 Called "List_Nr". WML
Prog = "Ascii_Display"
Const Sp_Characters = "NUL,SOH,STX,ETX,EOT,ENQ,ACK,BEL,BS,TAB,LF,VT,FF," & _
"CR,SO,SI,DLE,DC1,DC2,DC3,DC4,NAK,SYN,ETB,CAN,EM," & _
"SUB,ESC,FS,GS,RS,US"
Value = Asc(Char)
If Value < 32 Then
Ascii_Display = "(" & List_Nr(Sp_Characters, ",", Value + 1) & ")"
ElseIf Value < 127 Then
Ascii_Display = Char
Else ' Value >= 127
Ascii_Display = Format(Ascii_Display, "(###)")
End If
End Function ' Ascii_Display()
This function compares two strings:
VBA Code:
Function Ascii_Compare(Arg1, Arg2)
' Debugging Function: Compare 2 Ascii Strings.
' 1/22/18 Moved output to Intermediate Window. WML
Prog = "Ascii_Comp"
Display1 = Ascii(Arg1)
Display2 = Ascii(Arg2)
Ascii_Compare = (Arg1 = Arg2) & vbCr & "(1): " & Display1 & vbLf & "(2): " & Display2 & vbCr
End Function ' Ascii_Compare()