|
本帖最后由 fyupeng 于 2010-12-23 20:35 编辑
t小宝 发表于 2010-12-23 20:26
解决了,能贴出你的代码看看吗
Function EncodeString(strWords)
Dim i As Long
Dim strEncodeWords
For i = 1 To Len(strWords)
If CStr(Asc(Mid(strWords, i, 1))) = "-23116" Or CStr(Asc(Mid(strWords, i, 1))) = "-23124" Or CStr(Asc(Mid(strWords, i, 1))) = "-23122" Or CStr(Asc(Mid(strWords, i, 1))) = "-23120" Or CStr(Asc(Mid(strWords, i, 1))) = "-23118" _
Or CStr(Asc(Mid(strWords, i, 1))) = "-23114" Or CStr(Asc(Mid(strWords, i, 1))) = "-23112" Or CStr(Asc(Mid(strWords, i, 1))) = "-23110" Or CStr(Asc(Mid(strWords, i, 1))) = "-23099" Or CStr(Asc(Mid(strWords, i, 1))) = "-23097" _
Or CStr(Asc(Mid(strWords, i, 1))) = "-23095" Or CStr(Asc(Mid(strWords, i, 1))) = "-23075" Or CStr(Asc(Mid(strWords, i, 1))) = "-23079" Or CStr(Asc(Mid(strWords, i, 1))) = "-23081" Or CStr(Asc(Mid(strWords, i, 1))) = "-23085" _
Or CStr(Asc(Mid(strWords, i, 1))) = "-23087" Or CStr(Asc(Mid(strWords, i, 1))) = "-23052" Or CStr(Asc(Mid(strWords, i, 1))) = "-23076" Or CStr(Asc(Mid(strWords, i, 1))) = "-23078" Or CStr(Asc(Mid(strWords, i, 1))) = "-23082" _
Or CStr(Asc(Mid(strWords, i, 1))) = "-23084" Or CStr(Asc(Mid(strWords, i, 1))) = "-23088" Or CStr(Asc(Mid(strWords, i, 1))) = "-230102" _
Or CStr(Asc(Mid(strWords, i, 1))) = "-23104" Or CStr(Asc(Mid(strWords, i, 1))) = "-23106" Or CStr(Asc(Mid(strWords, i, 1))) = "-23108" Then
strEncodeWords = strEncodeWords & " "
Else
strEncodeWords = strEncodeWords & Chr(Asc(Mid(strWords, i, 1)))
End If
Next
EncodeString = strEncodeWords
End Function
声明一下,本人只要能写出来的,就不想用数组。呵呵。
Private Sub Command0_Click()
On Error GoTo Err_Command0_Click
Dim b As String
Dim x As String
Open Me![text1] For Input As #1 '源文件
Open Me![text1] & ".txt" For Append As #2
Do Until EOF(1)
Line Input #1, k
x = Replace(k, Chr(10) & "", Chr(13) & Chr(10))
Print #2, x
Loop
Close #1
Close #2
MsgBox "文件转换完毕!!!"
Exit_Command0_Click:
Exit Sub
Err_Command0_Click:
If Err.Number = 5 Then
b = EncodeString(k)
x = Replace(b, Chr(10) & "", Chr(13) & Chr(10))
Resume Next
else
msgbox err.number
resume next
End If
End Sub
看看有没有可以优化的地方?
|
|