VB程序如何将资源文件和代码文件分离?使得VB程序可以支持多语言版本

DashaLiu 2004-08-14 11:41:52
VB中是否存在方法可以通过类似编译宏或者切换资源文件的方式来达到支持多语言?还是有其它的办法,谢谢各位高手指点。
...全文
264 17 打赏 收藏 转发到动态 举报
写回复
用AI写文章
17 条回复
切换为时间正序
请发表友善的回复…
发表回复
junki 2004-10-12
  • 打赏
  • 举报
回复
根据语言的种类,
你多做几个资源文件不行吗?
要用时,调用不是很好吗??
关注……
死胖子 2004-10-12
  • 打赏
  • 举报
回复
tangyang8061(大保姆) (

万分同意这位兄台的话,,,顶。。。
yo_jo 2004-10-12
  • 打赏
  • 举报
回复
http://community.csdn.net/Expert/FAQ/FAQ_Index.asp?id=177472
tangyang8061 2004-09-01
  • 打赏
  • 举报
回复
为什么要切换资源文件?
vb本身一个资源文件就支持多语言啊.
jam021 2004-09-01
  • 打赏
  • 举报
回复
把要显示的字符串放到一个.ini的配置文件里,然后用GetProfile这个函数去读
比如:
// Name = "宋体"
-> Name = GetProfile("c:\aa.ini", "font", "font1")

Function GetProfile(strFileName As String, strSection As String, strName As String) As String

strSectionTemp = ""
strNameTemp = ""
strreturn = ""
On Error GoTo ErrReadFile
Open strFileName For Input As #1

'find node

Do While Not EOF(1)
strCharA = Input(1, #1)
If strCharA = "[" Then
Do While Not EOF(1)
strCharB = Input(1, #1)
If strCharB = "]" Then Exit Do
strSectionTemp = strSectionTemp & strCharB
Loop
End If
If strSectionTemp = strSection Then
strCharA = Input(2, #1)
Exit Do
Else
strSectionTemp = ""
End If
Loop
On Error GoTo ErrSrchSection

aa:

'find field

strNameTemp = ""
Do While Not EOF(1)
strCharA = Input(1, #1)
If strCharA <> "=" Then
strNameTemp = strNameTemp & strCharA 'gained name
Else
Exit Do
End If
Loop
If strNameTemp = strName Then
Line Input #1, strreturn
Else
Line Input #1, strreturn
GoTo aa
End If
Close #1
GetProfile = strreturn
Exit Function
ErrReadFile:
Dim inrRet As Integer
intret = MsgBox("read 'test.ini' failed!" & Chr(10) & "a file is missing or invalid", vbAbortRetryIgnore + vbExclamation, "error")
Select Case intret
Case vbAbort
GetProfile = ""
Close #1
End
Exit Function
Case vbRetry
Resume
Case vbIgnore
Resume Next
End Select
ErrSrchSection:
MsgBox "no node in 'ini' file", vbOKOnly + vbExclamation, "error"
GetProfile = ""
Close #1
End
End Function
DashaLiu 2004-09-01
  • 打赏
  • 举报
回复
根据楼上几位仁兄提供的解决办法,找了一些例子。
觉得在使用起来有点麻烦,且不管理起来不容易。

现在我们在评估这样一种解决方案,将窗体文件frm做两份,一个英文,一个中文。在编译英文版时,将frm中的文件替换成英文做的frm,替换时,只替换其中资源部分,如
VERSION 5.00
Begin VB.Form Form1
Caption = "**************"
ClientHeight = 1770
ClientLeft = 165
ClientTop = 735
ClientWidth = 4545
Icon = "Form1.frx":0000
LinkTopic = "Form1"
ScaleHeight = 1770
ScaleWidth = 4545
StartUpPosition = 3 '窗口缺省
Begin VB.CommandButton Command1
Caption = "################################"
Height = 375
Left = 3120
TabIndex = 1
Top = 360
Width = 1335
End
Begin VB.ComboBox Combo1
Height = 300
ItemData = "Form1.frx":030A
Left = 360
List = "Form1.frx":030C
TabIndex = 0
Text = "Combo1"
Top = 360
Width = 2415
End
Begin VB.Label Label2
AutoSize = -1 'True
Caption = "z.h_fw@163.com"
BeginProperty Font
Name = "宋体"
Size = 9
Charset = 134
Weight = 400
Underline = -1 'True
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
ForeColor = &H00C00000&
Height = 180
Left = 360
TabIndex = 3
Top = 1440
Width = 1260
End
End
不知道各位高手有什么建议或者更好的办法。
谢谢!!
DashaLiu 2004-08-16
  • 打赏
  • 举报
回复
TO :yonghengdizhen(等季节一过,繁花就凋落')
谢谢,我找一些示例学习
yonghengdizhen 2004-08-16
  • 打赏
  • 举报
回复
用xmldom访问xml结点啊.!
yijiansong 2004-08-16
  • 打赏
  • 举报
回复
学习
rainstormmaster 2004-08-15
  • 打赏
  • 举报
回复
用xml吧,都是树型结构
BlueBeer 2004-08-15
  • 打赏
  • 举报
回复
那就不要用资源文件了,用普通的文本文件做配置文件就行,很多的支持多语言的软件都是这样做的
界面上的文本按一定的格式写在文本文件里,程序运行时根据用户选择的语言读入存放在不同文件中的字符串
DashaLiu 2004-08-15
  • 打赏
  • 举报
回复
To:BlueBeer(1win) & rainstormmaster(暴风雨 v2.0)
请问您有具体的示例吗?
不知道具体该怎样做?
谢谢
ryuginka 2004-08-15
  • 打赏
  • 举报
回复
up
DashaLiu 2004-08-15
  • 打赏
  • 举报
回复
如果使用Xml文件,该如何处理呢?
有什么API函数可以读取xml吗?
DashaLiu 2004-08-15
  • 打赏
  • 举报
回复
To:cso(sjxsoft-天水是我家)
谢谢,已注册并下载
对我们有很大的帮助,再次感谢。
cso 2004-08-15
  • 打赏
  • 举报
回复
http://www.5ivb.net/down/30/5ivb_1940.asp
http://www.5ivb.net/down/11/5ivb_1792.asp

先注册后下载
DerryZhang 2004-08-15
  • 打赏
  • 举报
回复
Mark

7,763

社区成员

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

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