How do I print Ascii characters?

Visual Basic 2005 Express Edition:

I want to print arrow characters - up, down, right, left.

I see them them in the Wingding font, but, how do I find out which key to use to select those characters

Or, how do I know which ascii character number it is

I tried the following code:

For i As Integer = 0 To 255
RichTextBox1.Text = RichTextBox1.Text & i &
" "
RichTextBox1.Text = RichTextBox1.Text & Chr(i) & vbCrLf
Next

But, I need to switch fonts somehow in order to display i as a number, then chr(i) as a Wingding.



Answer this question

How do I print Ascii characters?

  • Clive76

    For any of the methods, I always get "s" instead of a left arrow.


  • John Simpson MAI

    You can use the Windows Charmap utility to find the codes. Start + Run, "charmap", OK.



  • Jim R32874

    For the left arrow in the Wingding font it tells me that the character code is 0xDF. I don't know what to do with that. I wish that it would give me the ASCII code (0 -255), then I could enter it by holding down the Alt key and entering the number.


  • 13yearoldgenius

    Try this on an empty form

    (watch out for the forums wordwrap on long lines.)

    Public Class Form1

    Private Sub Form1_Paint(ByVal sender As Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles Me.Paint

    Dim reg As Font = New System.Drawing.Font("Microsoft Sans Serif", 12.0!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))

    Dim wing As Font = New System.Drawing.Font("Wingdings", 8.25!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(2, Byte))

    e.Graphics.DrawString("s", reg, Brushes.Black, 10, 10)

    e.Graphics.DrawString("s", wing, Brushes.Black, 20, 20)

    End Sub

    End Class



  • Michael A Thomas

    Use Chr(&HDF). Note that character codes are no longer restricted to 0-255, the old Alt+number trick is no longer going to work.



  • shaeron

    Well,

    the trick will work for many of the characters. The one mentioned DF is 0223.

    (DF is hex, 0223 is decimal)

    Furjaw, the Microsoft calculator is the quick way to convert a hex number to decimal.

    Just put the calculator in scientific mode, type in a decimal number and click the hex radio button.

    Also the 'hold down alt' trick now seems to require the leading zero (0223 not 223) and the IDE seems to require keypad numbers instead of top line numbers.



  • Karl Hulme

    The funny looking 'b' when displayed/printed in wingdings font will display the arrow. You are viewing it in a regular font.

    Changing the font for the 'b' will display the arrow.



  • How do I print Ascii characters?