-
about 2 bytes ?
I have a trouble. In my experience,I used "sendmessage"to forbid inputing again with English words,and there is no trouble,but I changed into Chinese words, my computer only recongized the first chinese word. I think that the problem maybe relation about 2 bytes.
my source program
It needs one listbox,one textbox and command button.
Public Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hWnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
Public Const LB_FINDSTRING = &H18F
Private Sub Command1_Click()
Dim retrn As Long
Dim aa As String
aa = Text1.Text
retrn = SendMessage(List1.hWnd, LB_FINDSTRING, 0, ByVal aa)
If retrn = -1 Then
List1.AddItem Text1.Text
Else
List1.ListIndex = retrn
MsgBox "´ËÏîÖØ¸´,²»ÔÙÌí¼Ó"
End If
End Sub
Private Sub Form_Load()
With List1
.AddItem "ÕÅ·îÀú"
.AddItem "Àî·Ç"
.AddItem "ÎÅÏþÔ¶"
.AddItem "Áõ·ç¹â"
.AddItem "ÐíÕæÌì"
.AddItem "Íõ»áÀ¸"
End With
End Sub
use Chinese word " Îâºì", "Íõá°·Å", "Á÷Ïò"
-
Two-byte characters in VB are called Unicode.
If you use SendMessage api, you must send English as at least part of the message.
This is because the OS and it's components were written by English speakers.
Code:
This code locates characters in a textbox.
List1.ListIndex = SendMessage(List1.hwnd, LB_FINDSTRING, -1, ByVal CStr(Text1.Text))
the "LB_FINDSTRING" is a number represented by a constant. The constant is written in English characters. This is okay. You could use a number instead. The only part of the code that has to contain Chinese characters is what is in the TextBox.Text.
When you code in VB, limit yourself to code written with Western characters. Don't try to use Chinese characters except in literals.
If it helps try to transliterate - write meaningful Chinese variables naems using Western characters.
Label1.Caption = "chinese characters here"