[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
Solved

Listbox display of entire 256 IBM DOS ASCII char set

Posted on 1998-05-22
21
Medium Priority
?
660 Views
Last Modified: 2008-02-01
Back in the DOS days, every ASCII character from 1 through 256 had a screen representation. Ten years ago I wrote a Hex File Dump and ASCII Edit utility that allowed the contents of  ANY file to be viewed and edited. Now I want to write something similar in VB5.

But ... I'm having problems displaying characters less than ASC(32) and greater then ASC(127).

What I'm looking for is a mix of (A) a multi-line textBox-like control and (B) a fixed TrueType font ... such that when combined allows display of the entire old IBM 256 ASCII character set. The solution must be 32 bit and I'm willing to purchase a special control and purchase a font if necessary.

Please do not attempt to answer this question unless you've actually TRIED the solution you propose. I've been programming for 25+ years and this problem does NOT have a simple solution. Everything I've tried "almost" works but have not yet found a way to display characters below 32 (especially characters like line feed, carriage return and tab).

I've made this question worth a lot of points because I want a real working solution, not someone's guess.

Thanks for your help

=================> Frederick Volking

0
Comment
Question by:volking
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 6
  • 5
  • 5
  • +2
21 Comments
 
LVL 6

Expert Comment

by:clifABB
ID: 1456975
If you've been programming for 25+ years, then you know you *can't* print characters below 32.  What you would need is code along the lines of:
If sChar = Chr$(10) Then
  Print "<LF>"
ElseIf sChar = Chr$(13) Then
  Print "<CR>"
and so on...(personally, I would use a Select/Case statement)

As far as a font that looks like the old MSDos characterset, try Terminal.  It's available on (almost) all Win95/NT machines and it is very similar.
0
 
LVL 6

Expert Comment

by:clifABB
ID: 1456976
To continue, there is an applet in Windows called Character Map which will display characters for any font you have installed.  Windows doesn't install the applet be default, so if you can't find the shortcut in Start/Programs/Accessories, you will have to add it with the Add/Remove Programs in Settings/Control Panel.
0
 
LVL 5

Author Comment

by:volking
ID: 1456977
clifABB - You are wrong! Why did you Guess? I specifically asked for NO GUESSES!

It can be done. I know it can be done in DOS since I did it in two commercial product called DFD (Data File Doctor by Volking Software) and the second release called PDT (Programmers Data Tool by ProFormance Software). Of which I sold about $200,000 worth over 3 years.

I will emphasize ONE MORE TIME ... please DO NOT GUESS!

Thanks,
=================> Frederick
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 9

Expert Comment

by:cymbolic
ID: 1456978
volking, why can't you continue to use a DOS box display?  You know that is also a generated system font, and it does represent all the characters, so why must it only be in a windows control display?  You can easily create a DOS task and wait for completion, and even position the window externally so that it looks like it is part of your windows app.

By the way there is a clue there.  It is done in a DOS box right now in Windows, so you know it can be done in Windows, since that also using a windows generated font.

0
 
LVL 6

Expert Comment

by:anthonyc
ID: 1456979
Use the Terminal Font...  I did it using a listbox, and all chars print but 32, and that's a space so I guess it really did print.


Volking:  Your attitude definitely leaves a lot to be desired.
0
 
LVL 5

Author Comment

by:volking
ID: 1456980
You propose an excellent idea however communication between the DOS window and VB5 is far beyond my knowledge level. The Hex Dump/ASCII Editor window is but a small portion of the overall functionality in the utility so I would need to setup intimate communication between the two. Simply stated, VB5 would need to print material to the DOS window and keystroke input from a cursor in the DOS window would need to be received by the VB5 application ... a tough scenario.

But thanks for your suggestion!

=============================> Frederick
0
 
LVL 6

Expert Comment

by:clifABB
ID: 1456981
I must deeply apologize.  I just wrote a scathing flame a mile high.  I had to delete it, though.  I just remembered the smiley face at chr$(1).

Unfortunately, you will not be able to find a font (true-type or other) which will dispaly any characters under 32.  This is a Windows thing.  Even if you tried to print a chr$(9), Windows will interpret it as it sees fit (as a tab).

To quote the VB Help file:
"Values 8, 9, 10, and 13 convert to backspace, tab, linefeed, and carriage return characters, respectively. They have no graphical representation but, depending on the application, can affect the visual display of text."
-----------------------------------------------
I will submit this as a comment, once you get this statement verified by other users and you accept that it can't be done, I hope you will give me the opportunity of submitting "It can't be done" as an answer.
0
 
LVL 5

Author Comment

by:volking
ID: 1456982
AnthonyC - Thanks for your answer. At least you've tried your proposed solution. But what you suggest I've already tried and there's two problems. Here ... try this:

Text$ = String$(255, "X") + Chr$(13) + Chr$(10)
For C% = 1 To 255
Text$ = Text$ + Chr$(C%)
Next
Text1.Text = Text$

The two lines are not identical lengths. Right? Because the tab (CHR$(9)) is translated & expanded. AND the two character pair  of (Chr$(13) + Chr$(10) is also translated into a line wrap otherwise the output would be one long line.

As I said, this is not an easy problem.

I apologize if my words to clifABB were abrupt. It was unintentional on my part. I was simply trying to be specific.

================================> Frederick

0
 
LVL 6

Expert Comment

by:clifABB
ID: 1456983
I stand corrected yet again (boy, I'm batting .000)

Terminal (which I suggested originally) does print a smiley face at chr$(1) as well as all the other DOS characters.
0
 
LVL 6

Expert Comment

by:clifABB
ID: 1456984
Volking, I have tried the code you suggested above in DOS and the chr$(9) is expanded there as well.  Also, the chr$(13) drops the printing down one line.
0
 

Expert Comment

by:dochopper
ID: 1456985
If you want a sample of using a DOS "console" there is a smple of doing just that in the VB owner's area on MSs VB site.  If you can't get there, e-mail and I'll post it.  Just thought it might be of help.
0
 
LVL 6

Expert Comment

by:anthonyc
ID: 1456986
You may have to do a mask for the TAB key.. but not too much else (since the tab Key you describe is actually printing properly... it's representation is more than 1 space)
0
 
LVL 5

Author Comment

by:volking
ID: 1456987
AnthonyC - That is exactly where I find myself right now. The only way I've found to make it work is to filter (a) all tab chars and (B) all CR+LF pairs. As a bad-case I could make it work. But I'd rather find a real solution ... thus this question.

I'll wait 24 hours then raise the points to 1,500 (which will wipe-out my account) but I really do want a clean solution.

Thanks for all your help.

=======================> Frederick
0
 
LVL 5

Author Comment

by:volking
ID: 1456988
Changed my mind... why wait 24 hours ... if somone can solve this problem it's worth cleaning out my account. Heck, I'd even be willing to pay a few dollars, so email me direct if you're willing to work on this one.

FVOLKING@VISA.COM

====================> Frederick Volking
0
 
LVL 9

Expert Comment

by:cymbolic
ID: 1456989
Check this out in the Microsoft Knowledge base.  

How to Print the ASCII Character Set in Visual Basic

Last reviewed: June 21, 1995
Article ID: Q75857
0
 
LVL 9

Expert Comment

by:cymbolic
ID: 1456990
0
 
LVL 5

Author Comment

by:volking
ID: 1456991
Cymbolic - This may be my answer!

I had to convert the API calls from VB3 to 32bit VB5 but the danged thing works! There's still a few problems like the text disappears when overlayed by another window and turning on the form's AutoRedraw makes the code stop working entirely ... but I might be able to make it work.

Please change your "Comment" posting to an "Answer" posting so we seal the question, then let me experiment for a day and verify that I can make it all work.

Many thanks!

I'll keep you posted.

=====================> Frederick
0
 
LVL 6

Accepted Solution

by:
anthonyc earned 5960 total points
ID: 1456992
here is source that works:


0
 
LVL 6

Expert Comment

by:anthonyc
ID: 1456993

Sub Command1_Click()
    Dim iSaved  As Integer
    Dim iHeight As Integer
    Dim lOEM    As Long
    Dim lObject As Long
    Dim iX      As Integer
    Dim iY      As Integer
    Dim szEdge  As String
    Dim szOut   As String
    Dim lRet    As Long
    Dim iCt     As Integer
    Dim iCt2    As Integer
   

      Dim hOEM As Integer   '*handle the OEM Font Object
      Dim y, H As Single

      '*save the scale mode so that you can reset later
      iSaved = Picture1.ScaleMode

      '*alter the current scale mode
      Picture1.ScaleMode = vbPixels

      '* get the character height and subtract the external leading
      iHeight = Picture1.TextHeight(Chr$(200)) - 1

      '* get the handle to the desired font
      lOEM = GetStockObject(OEM_FIXED_FONT)

      '* select the object relating to the font handle
      lObject = SelectObject&(Picture1.hdc, lOEM)

      '* if successful then print the desired characters.
      If lObject > 0 Then

         '* establish border
         szEdge = "0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 "

         '* initialize output location
         iX = 10
         iY = 10

         '* position cursor & print top border
         Picture1.CurrentX = iX
         Picture1.CurrentY = iY
         
         '* print top ruler edge
         szOut = "  " + szEdge + "  "
         lRet = TextOut(Picture1.hdc, iY, iX, szOut, Len(szOut))

         '* Cycle through 256 characters beginning at character 0
         For iCt = 0 To 15

            '* prep left border
            szOut = Mid$(szEdge, (iCt * 2) + 1, 2)

            '* assemble string of characters
            For iCt2 = 0 To 15
                szOut = szOut + Chr$((iCt * 16) + iCt2) + " "
            Next

            '* prep right border
            szOut = szOut + Mid$(szEdge, (iCt * 2) + 1, 2)

            '* prepare for display at next row
            iX = iX + iHeight

            '* print the assembled string of characters
            lRet = TextOut(Picture1.hdc, iY, iX, szOut, Len(szOut))

         Next

         '* prepare for display at next row
         iX = iX + iHeight

         '* print bottom border
         szEdge = "  " + szEdge + "  "
         lRet = TextOut(Picture1.hdc, iY, iX, szOut, Len(szOut))

         '* reinstate the previous font
         lOEM = SelectObject(Picture1.hdc, lObject)

      Else

         '* SelectObject was unsuccessful
         MsgBox "Couldn't Find OEM Fonts", 48

      End If

      '* reset the scale mode
      Picture1.ScaleMode = iSaved
   End Sub



0
 
LVL 6

Expert Comment

by:anthonyc
ID: 1456994
Option Explicit

 ' Enter each Declare statement on one, single line.
Declare Function GetStockObject Lib "gdi32" (ByVal nIndex As Long) As Long
Declare Function SelectObject Lib "gdi32" (ByVal hdc As Long, ByVal hObject As Long) As Long
Declare Function TextOut Lib "gdi32" Alias "TextOutA" (ByVal hdc As Long, ByVal x As Long, ByVal y As Long, ByVal lpString As String, ByVal nCount As Long) As Long

Public Const OEM_FIXED_FONT As Long = 10



0
 
LVL 9

Expert Comment

by:cymbolic
ID: 1456995
Cymbolic - I have to believe that AnthonyC was working on his "proof" when you posted your Q75857 resource. Since I originally made such a stink about wanting a solution that had been "tried", I think AnthonyC's answer best suited my request. By the way, AnthonyC's Proof works great!

Thanks AnthonyC! Thanks Cymbolic!

I sincerely appreciate BOTH your effort.

===========================> Frederick Volking
0

Featured Post

Ask an Anonymous Question!

Don't feel intimidated by what you don't know. Ask your question anonymously. It's easy! Learn more and upgrade.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Suggested Courses

650 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question