If you are talking about the Properties Window in the IDE, then yes. Also setting the Caption to a literal String in code does the same thing. All literal values in VB6 are ANSI.
Thank you, that's what I thought.
I am really confused about using Unicode characters.
For example:
I can paste directly into Text Box the Unicode text.
It is displayed correctlly, but when the same Text Box is loaded programmatically with the same text , the text is not displayed correctly.
Even when the text is displayed properly (by pasting it), analyzing it byte by byte does not show that right.
What I want to do is just display Unicode text in the Text Box programmatically, just to have the same visual effect as by pasting unicode text.
Thanks,
jas
Maybe I will explain that more.
I have the unicode text stored as a text file.
When I open that file in Notepad, I can copy and paste that text into TextBox and the text is displayed properly.
However, when programmatically I open that file (for Binary), read that file byte by byte and display the result in TextBox the result is not the same as pasting.
Why?
Last edited by jastrzebiec; Jul 4th, 2012 at 12:55 AM.
I have a problem when trying to load Microsoft Forms 2.0 Object Library component in Windows 7 Ultimate 64 bit.
Check to see if you have FM20ENU.Dll installed.
FM20ENU.Dll - Automatically installed with English versions of Office. Users who have installed Office with another language should check Windows\System32 folder for presence of this file. If it is not present you can download and install it free as part of ActiveXControlPad. You must have FM20ENU.Dll present to make Forms 2.0 Object Library controls available in Vb6. The symptoms are that the controls appear in the Vb Toolbox panel but an error occurs when you try to place one onto a form. http://download.microsoft.com/downlo...S/setuppad.exe
Just as a quick note. the FM20*.dll is not freely redistributable with our applications. The only way to do this correctly is to first (download and) install the ActiveX Control Pad and then the application. the FM20 dll cannot be included as part of the VB's setup app.
Or at least this is the way it used to be years ago. I don't know if this has changed. More info:
Note the last paragraph before the "References" section. What this means is that MS might change the way that these controls work in future releases of the FM20 DLL which might break your code. Of course since ths is from years ago, perhaps at this time this is no longer applicable. Regards,SgarV.
I believe that if I did not have installed that file then it would be impossible to select
Microsoft Forms 2.0 Object Library from the Components list.
Besides that, I have tried your link for setup.
1.
When I save it to a file and run it I have "....not valid Win32 application" error.
2.
When I run it from web I have: "The application was unable to start correctly..." error.
Thanks,
jas
I believe that if I did not have installed that file then it would be impossible to select Microsoft Forms 2.0 Object Library from the Components list.
It will appear in Component list. You just can't instantiate a control without FM20ENU.DLL.
This is a known issue.
OK, I am giving up on Microsoft Forms 2.0 Object Library component.
But maybe there is an another way to do what I need.
I have tested it and I can confirm that Clipboard can keep Unicode strings.
I do not need to display that string.
I need to pass it to T-T-S voice in unchanged format.
How to do that?
When I use Clipboard.GetText directly like for example this:
moVoice.Speak Clipboard.GetText, flags
the voice speaks ANSI not Unicode.
Any idea how to accomplish that?
/jas
One more question.
How to store Unicode string within vbasic code?
Let say the Unicode text from Clipboard is kept by lpString variable.
How to store that to the file and retrieve that later?
Thanks,
jas
Unicode File I/O requires a UTF-16 BOM marker and must use binary file I/O.
Here are 2 functions to Write/Read Unicode text to file.
Code:
Option Explicit
Private Sub Form_Load()
Dim sUni As String
sUni = "JPN: " & ChrW$(&H3088) & ChrW$(&H3046) & ChrW$(&H3053) & ChrW$(&H305D)
UnicodeFile_Write_VB App.Path & "\UniTest.txt", sUni
'Prove it works
sUni = UnicodeFile_Read_VB(App.Path & "\UniTest.txt")
MsgBox sUni, vbInformation, "Unicode File I/O"
End Sub
'Purpose: Override Vb6 MsgBox with Unicode aware MsgBox. HelpFile/Context not supported.
Function MsgBox(Prompt As String, Optional Buttons As VbMsgBoxStyle = vbOKOnly, Optional Title As String) As VbMsgBoxResult
MsgBox = CreateObject("WScript.Shell").Popup(Prompt, 0&, Title, Buttons)
End Function
'Purpose: Note that sFileName must be ANSI. The content can be Unicode or ANSI.
Public Function UnicodeFile_Read_VB(ByVal sFileName As String) As String
Dim FF As Long
Dim b() As Byte
Dim s As String
On Error Resume Next
FF = FreeFile
Open sFileName For Binary Access Read As FF
ReDim b(LOF(FF) - 1)
Get FF, , b
Close FF
'Detect file encoding
If b(0) = 255 And b(1) = 254 Then 'UTF-16 BOM FF FE
s = b
s = Mid$(s, 2) 'Remove BOM
Else
s = StrConv(b, vbUnicode) 'ANSI file
End If
UnicodeFile_Read_VB = s
End Function
Public Sub UnicodeFile_Write_VB(ByVal sFileName As String, _
ByVal strText As String, _
Optional ByVal bUnicode As Boolean = True)
Dim FF As Long
Dim b() As Byte
On Error Resume Next
Kill sFileName
On Error GoTo 0
FF = FreeFile
Open sFileName For Binary Access Write As #FF
If bUnicode Then
Put #FF, , CInt(&HFEFF) 'UTF16 BOM
b = strText
Else
b = StrConv(strText, vbFromUnicode)
End If
Put #FF, , b
Close #FF
End Sub
Boy, thank you very much.
Surely, you deserve your title!
One extra question. I believe I can keep it such binary file in my Resource file.
Is there some special way to read it back?
Thanks,
jas
Basically all you need to do for Unicode strings in a resource file is just paste them in using Notepad and clicking SaveAs where you specify Encoding as "Unicode". This ensures that a UTF-16 BOM marker is inserted at beginning of file and that the strings are saved as Unicode.
Finally compile this file using Rc.exe
Attached is a sample Unicode resource file, a batch file to compile it and the final .Res file.
All you need to do is load the string using Vb "LoadResString(iD)" and you will have Unicode.
Demo has Unicode aware MsgBox since Vb6 MsgBox is ANSI only.
Note: Once you have a string saved as a file you can cut/paste into a new Notepad file and create your resource.
Last edited by DrUnicode; Jul 7th, 2012 at 10:42 AM.
Reason: Screenshot