Chinese characters appearing in my strings ?!!?!?!

G

Guest

Afternoon all,

I'm pulling my hair out with this one, for some reason (only when using vba)
i will write (english) strings to go into text/msg boxes or more specifically
an automated email message and it will come through in either Chinese
characters or just muddled symbols?

Is this something really obvious i've missed or have i really messed
something up?

Any more info needed just ask!

Mike (Access 2003)
 
J

John Nurick

Hi Mike,

Usually this sort of thing comes down to fonts or text encoding.

1) Are you using an English version of Windows and of Office?

2) Does it happen in all databases, or only one, or only some?

When you say "come through" I take it you mean you do something like
this:

'set value of a text box from VBA
Forms("MyForm").Controls("txtXXX").Value = "Some ordinary text"

but when you look at the form later, txtXXX contains Chinese
gibberish. While the form is displayed, try something like this in the
Immediate pane:

S = Forms("MyForm").Controls("txtXXX").Value

For j = 1 to Len(S) : ? j, Mid(S, j, 1), Asc(Mid(S, j ,1)),
Chr(Asc(Mid(S,j,1))) : Next

For.. to ..Next must all be on one line. This will list each character
in the textbox, followed by its ANSI code and then convert the ANSI
back to a character.

Repeat, using AscW and ChrW in case Unicode is a factor.

If all the characters match the string you originally assigned to the
textbox, I'd assume that the problem relates to differences between
the fonts in the VBA editor and the textbox (or maybe code pages or
the equivalent.

If the ANSI or Unicode values don't survive the round trip, then
something else is going on. Could some other process be changing
things?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top