Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Visual Basic > VB 6 Visual Basic 6 > Beginning VB 6
|
Beginning VB 6 For coders who are new to Visual Basic, working in VB version 6 (not .NET).
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Beginning VB 6 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old February 26th, 2006, 08:46 AM
Registered User
 
Join Date: Feb 2006
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default Display ASCII chars (128 to 255) in a TextBox

:)My project is a simple terminal VB6 program (based on the sample VBTerm).

I am using a RichTextBox to display received characters from a COM port.
The problem is with characters in the range 128 to 255.
They are not displayed as I'd expect.
I want these characters to be in codepage 437 (i.e. box drawing and block characters).
I have tried using Terminal and Arial Unicode MS fonts, I have even tried playing with
the \ansicpg control word, \'xx and \uN special characters.

I am competely lost !!
Any help would be most appreciated.

Thanks, VB newbie

 
Old June 24th, 2006, 10:00 AM
Authorized User
 
Join Date: Jun 2006
Posts: 73
Thanks: 1
Thanked 1 Time in 1 Post
Default

Maybe. each ANSI/ASCII character has a corresponding number code which is referred to in code as follows Chr(n), where 'n' is the related integer. If you think this might help, send more info.liamfitz.

 
Old June 28th, 2006, 09:01 AM
Registered User
 
Join Date: Jun 2006
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I'm having the same trouble.

I load up a text file into a nomal vb.net textbox and dont see any of the special ascii chars, used in ascii art.

Anyone know how to show these characters just like in the original textfile? It works perfectly with vb6.

 
Old June 28th, 2006, 12:57 PM
Friend of Wrox
 
Join Date: Nov 2004
Posts: 1,621
Thanks: 1
Thanked 3 Times in 3 Posts
Default

Perhaps richtext has a designator that specifies that everything that follows is literal.
I don't know that it does, but this is where I would look first. (HTML has block designators to do just that, for instance.)
Plus, make sure that the font you are using has representative images in the ASCII range you are talking about.
 
Old June 29th, 2006, 08:22 AM
Registered User
 
Join Date: Jun 2006
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks Brian, thats really usefull, I'm having real dificulty finding anyone with the same problem on google :)

Care to explain how this "designator" in your HTML example works?

I have tried using "courier new" font and "Lucinda Console" but both of them only show the first 127 ascii chars.

Interestingly, I have tested it by copying a higher ascii char into the textbox while the program is running and this works fine, so I am now looking at how Im loading the textfile in the first place using the streamreader class.

I got this working with VB6 using a loop reading it line by line so maybe this will work in vb.net express but who knows :)

 
Old June 29th, 2006, 08:44 AM
Registered User
 
Join Date: Jun 2006
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Oh Well, on writing my reply I realised that I'm beign really stupid and reading the text file in as a binary. A quick look on MSDN for the streamreader class shows lots of text encoding options.

For anyone else's reference this worked for me:

Code:
'Get a new StreamReader in ASCII format from a
'file using a buffer and byte order mark detection
Dim SrAsciiFromFile As StreamReader = New StreamReader("C:\Temp\Test.txt", System.Text.Encoding.default)
The important part is the addition of "system.text.encoding.default"

Again thanks to all who helped :) the final piece of my vb6 > dot net conversion is done.

 
Old June 29th, 2006, 01:50 PM
Friend of Wrox
 
Join Date: Nov 2004
Posts: 1,621
Thanks: 1
Thanked 3 Times in 3 Posts
Default

To expound some on what I had said earlier (despite its apparent lack of usefulness . . . :

Rich text, html, literal strings in various programming languages, et al., need some way to differentiate between data and instructions. For instance, in C and Java, to add a " to a string you precede it with a backslash (\"). In VB, pairs of "s are interpreted as one literal ": ("I am Bob ""The Man"" Smith" turns into I am Bob "The Man" smith). (I just used an escape sequence to create red text. The characters "[ r e d ]" {but without the spaces} are not treated as data, but as instructions.)

I don't know a lot about rich text, but I have seen that it appears that instructions are enclosed in curly braces.

In HTML, to add a block literally (no "interpretation" by the markup engine), you use
Code:
<blockquote> 
    literal stuff goes here... 
</blockquote>
(I told WROX’s site to be literal just above using "[ c o d e ]" and "[ / c o d e ]," again without the spaces.)

Looking into some rich-text reference work should prove more helpful than picking my brain on RTF, because (like Schultzy says repeatedly in Hogan’s Heroes: "I know nuhthink!"; sorry.

Brian
 
Old April 11th, 2007, 02:22 AM
Registered User
 
Join Date: Apr 2007
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via ICQ to Goddchen
Default

hi i have exactly the same problem :( i tried font: lucida console, lucida console ASCII, MSI Console, nothing works. i just see strange Üs and so on in my textbox :( when i save the textfrom the textbox back to a file and open it in windows editor everything is just fine... so it's not an encoding problem, it has to be a displaying problem :( i don't know what to do :(

Gr33tz

 
Old August 6th, 2007, 10:47 AM
Registered User
 
Join Date: Aug 2007
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi all,
i had the same Problem:
VB6, RTF-Control, Characters from 128 to 159.

After searching hours and hours to a solution i decided to solve it by my selve. So i searched a Rich-Text Format Specification:
http://latex2rtf.sourceforge.net/RTF-Spec-1.2.pdf

After study the document i found two important things:
1.) You can select the codepage by the \cpg tag
2.) You can insert an charachter by using the\' tag

And here i present my solution: (

Code:
Dim CharCode as Byte
CharCode = 130 'You can use values from 0 to 255
RichTextBox1.SelRTF = "{\cpg1252\'" & Right("00" & Hex(CharCode), 2) & "}"
Try it out, it works fine...
Ciao,
Mani






Similar Threads
Thread Thread Starter Forum Replies Last Post
How to get and display a data in textbox kakac ASP.NET 2.0 Basics 1 April 20th, 2007 08:12 AM
how to display value to textbox tllcll Javascript 1 October 27th, 2005 09:10 AM
SQL statement limited to 255 chars Mikeopolo Excel VBA 1 February 18th, 2005 09:20 AM
Display ASCII file using xsl... bmagadi XSLT 0 February 10th, 2005 07:52 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.