to:wooin (帅是天意,酷是人为!).about:应该怎么做中英文版的软件,选择语言后界面就自动变了
qixg 2003-02-20 11:21:53 wooin (帅是天意,酷是人为!) ,你好:
我回过你的问题:应该怎么做中英文版的软件,选择语言后界面就自动变了。。
我给了你一点提示,但好像还不够:)。以下是完整的解决方案。
1.Form1内加两个Command控件,分别命名cmd1001和cmd1002,以下是Form1内的代码:
Option Explicit
Private boolChinese As Boolean
Private Sub cmd1001_Click()
boolChinese = True
subSetLanguage
End Sub
Private Sub cmd1002_Click()
boolChinese = False
subSetLanguage
End Sub
Private Sub Form_Load()
boolChinese = True
subSetLanguage
End Sub
Private Sub subSetLanguage()
''获取资源文件路径.
Dim strFilePath As String
strFilePath = App.Path
''设置语言
''选择语言文件
Dim strLanguageFile As String
If boolChinese = True Then
strLanguageFile = strFilePath & "\chinese.txt"
Else
strLanguageFile = strFilePath & "\english.txt"
End If
Dim longFreeFile As Long '获得当前可用文件号
longFreeFile = FreeFile
Dim strCmdCaption As String
Dim control As Variant '作为循环查找变量
Open strLanguageFile For Input As #longFreeFile
Do While Not EOF(longFreeFile)
Line Input #longFreeFile, strCmdCaption
'查找名字应对应得变量
For Each control In Me
With control
If Right(.Name, 4) = Left(strCmdCaption, 4) Then
control.Caption = Right(strCmdCaption, Len(strCmdCaption) - 5)
End If
End With
Next
Loop
Close #longFreeFile
End Sub
2.建立两个资源文件chinese.txt和english.txt,保存在工程路径下。
文件内容:
chinese.txt: 1001=(&C)中文
1002=(&E)英文
english.txt: 1001=&Chinese
1002=&English
此种方法也可以应用于菜单,我在机器上试过了,没问题。这次行了吧,嘿嘿我要分!:)。如还有问题请给
我留言。
From:qixg(⊙∠⊙)