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(⊙∠⊙)
...全文
48 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
用户 昵称 2003-02-21
  • 打赏
  • 举报
回复
收藏
qixg 2003-02-20
  • 打赏
  • 举报
回复
请高手指教。
qixg 2003-02-20
  • 打赏
  • 举报
回复
wooin (帅是天意,酷是人为!),我本想给你留言,但发不了这么长的。

7,763

社区成员

发帖
与我相关
我的任务
社区描述
VB 基础类
社区管理员
  • VB基础类社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧