Barry James wrote:
> I have created a VB6.0 database application for WWF (World
> Wide Fund for Nature not World Wrestling Federation!).
Oh, well, if it is for the whales, I'll try to be helpful. :-)
> [...]
> My gut feeling is that I should stick with the Access 2000
> version and try to convert the strings within VB as I have
> more control over the VB forms than over the Active
> Reports.
It seems a sound choice. I think that the important question is now: what
does the "garbage" look like?
I know these two possibilities:
1) It looks like empty squares;
2) It looks like question marks.
In case 1, you just have a font problem: the Cyrillic characters are there
but the font you use doesn't have glyphs for them. Although I don't expect
that this is the problem, you could fix it by setting each control's font
face to a proper font. E.g.:
cmdMyButton.Caption = "Чао а тутто ил мондо!"
cmdMyButton.Font.Name = "MyCyrillicFont"
In case 2 (which is what I would expect), you have a conversion problem.
Unfortunately, VB controls up to 6.x do not support Unicode. Unicode is
supported internally (you can have Unicode strings), and it is supported the
conversion from Unicode to Windows' character set and vice versa, but the
controls themselves must be in one Windows character set. In this case, you
have to change each control's encoding *before* you set its text/caption
with Cyrillic text:
Const charsetCyrillic As Integer = 204
cmdMyButton.Font.Charset = charsetCyrillic
cmdMyButton.Font.Name = ""
cmdMyButton.Caption = "Чао а тутто ил мондо!"
Setting the font name to an empty strings causes the Font object to choose
the default font for the control's code page. Of course, you can also
explicitly set a font name that you know supports that code page.
I found value 204 by experimentation; unfortunately, I don't know where to
find a complete list of supported character sets, but here are the ones I
found out:
Const charsetWestEurope As Integer = 0
Const charsetDefault As Integer = 1
Const charsetSymbol As Integer = 2
Const charsetJapanese As Integer = 128
Const charsetKorean As Integer = 129
Const charsetChineseS As Integer = 134
Const charsetChienseT As Integer = 136
Const charsetGreek As Integer = 161
Const charsetTurkish As Integer = 162
Const charsetHebrew As Integer = 177
Const charsetArabic As Integer = 178
Const charsetBaltic As Integer = 186
Const charsetCyrillic As Integer = 204
Const charsetEastEurope As Integer = 238
Const charsetDosBox As Integer = 255
Note that this approach implies that you keep the charset information
together with each language choice, and that you change each control's
charset each time that the language changes.
If it was my task, I'd prefer to have centralized code which loops through
all the forms and controls in the application to set their charset. E.g.:
Sub setCharset(ByVal iCharset As Integer)
On Error Resume Next
Dim iFrm As Integer
For iFrm = 0 To Forms.Count
Dim iCtl As Integer
Forms(iFrm).Font.Charset = iCharset
Forms(iFrm).Font.Name = ""
For iCtl = 0 To Forms(iFrm).Controls.Count - 1
Select Case
TypeName(Forms(iFrm).Controls(iCtl))
Case "ActiveReport"
' (Or whatever the actual
type name is...)
' DO NOTHING
Case Else
Forms(iFrm).Controls(iCtl).Font.Charset = iCharset
Forms(iFrm).Controls(iCtl).Font.Name = ""
End Select
Next iCtl
Next iFrm
End Sub
But perhaps you already a similar loop to set each control's caption with
localized strings. In this case, you can set the charset within the existing
code. Remember to set the charset before you set the caption!
Note that this approach implies that all forms are loaded (although not
necessarily shown) at start up, because the object <Forms> only contains
loaded forms. The form's menu should be just one more control, thus it
should be handled by the loop as well.
Hopefully, one version of VB will arrive one day whose controls are fully
enabled to Unicode and smart fonts. So, all this code could be put inside
<#If>'s so that it can be disabled when porting to newer Visual Basic.
I hope this helps.
_ Marco
This archive was generated by hypermail 2.1.2 : Thu Mar 28 2002 - 07:55:03 EST