Ascii Debuging Functions

Mackeral

Board Regular
Joined
Mar 7, 2015
Messages
232
Office Version
  1. 365
Platform
  1. 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:
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()
 

Excel Facts

How to find 2nd largest value in a column?
MAX finds the largest value. =LARGE(A:A,2) will find the second largest. =SMALL(A:A,3) will find the third smallest
Your Ascii_Display function is calling another function that you have not listed for us... the List_Nr function.
 
Upvote 0

Forum statistics

Threads
1,215,059
Messages
6,122,916
Members
449,093
Latest member
dbomb1414

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top