Why do ASCII characters differ from Excel for presentation through code in VBA?

1

Does anyone know why this occurs?

I need to use characters from the " Wingdings 3 " font in Labels dynamically created in a VBA

If these Labels are created directly on the form the problem does not occur, for example, when creating a Label and copying the desired character in your Caption and selecting the " Wingdings 3 ", the Label displays the character correctly, however, when using Chr (131) in the code for the Caption of another Label , something like the Chr (156) character of the same font appears. (Instead of a full left arrow, a small, fine right arrow appears.)

The code below lists some characters from this font, and it is clear that they differ totally from the ASCII characters of Excel accessed by Menu: Insert / Symbols / / strong>.

Can you solve this or am I doing something wrong?

Dim i As Integer

Dim str As String

str = ""

For i = 33 To 255

  str = str & Chr(i)

Next i

Label1.Width = 500

Label1.Height = 500

Label1.Font.Name = "Wingdings 3"

Label1.Caption = str
    
asked by anonymous 18.03.2016 / 16:35

1 answer

2

The solution was as follows:

I ran a test and I placed two Labels on the form and one of them I changed the font to " Wigdings 3 " and the other one was " Tahoma ".

I have changed the font of the two Labels to Wingdings 3 , but by sending the Chr (i ) with i values , Label with Wingdings 3 the characters correctly, that is, the command I gave to change the Label font is not being recognized in the code execution by VBA .

So, to use ASCII characters 127 by code in VBA the same font you want in the object that will receive these characters, otherwise, if they are parameterized with other fonts these characters will not match those that are presented by Excel (Insert / Symbols / Symbol), even when the font of the object is altered by the code.

    
02.07.2016 / 22:53