# Re: 中文档案的转换

Posted by 小琳 on July 14, 1999 at 21:24:19:

In Reply to: 中文档案的转换 posted by scenario on July 13, 1999 at 13:37:32:

: 如果我要把一文字档，中文字的部份加上 \A 的字串，
: 英文字则原封不动的复制，写到另一档案内，
:
: 即：
: a.txt
: 学VB找小吴
:
: b.txt
: \A学VB\A找\A小\A吴
:
:
: 要如何做，又如果我想在遇到某一字串之后，
: 停止在每一中文字前写入 \A ，
: 原封不动的复制其余的档案又如何做。
:
:

:::小女子看了您的问题后，就写了一个小小的程式，希望
能够帮您解决问题，程式如下：

Private Sub Command1_Click()
Dim temp As String, s As String
Dim s1() As Byte
Dim i As Integer, j(1) As Byte
Dim result As String

Open App.Path & "\a.txt" For Input As #1
Open App.Path & "\b.txt" For Output As #2
Do
temp = Input(1, #1)
s = s & temp
Loop While Not EOF(1)
s1 = StrConv(Trim(s), vbFromUnicode)
For i = 0 To UBound(s1) - 2
If s1(i) > 127 Then
j(0) = s1(i)
j(1) = s1(i + 1)
i = i + 1
result = result & "\A" & StrConv(j, vbUnicode)
Else
result = result & Chr(s1(i))
End If
Next i
Write #2, result
Close #1, #2
' For i = 0 To LenB(s1)
End Sub

Follow Ups: