怎么使用StrConv转换,可否举例?另外: zmazmapk(安安),我真是不知道你是怎么学VB的,居然读文件还那么复杂,看看我的:
function readfile(filename as string) as string
Dim FreeMem as integer,byt() as byte,s as string
freemem=freefile
open filename for binary as freemem
redim byt(lof(freemem))
get #freemem,,byt
s=strconv(byt,vbunicode)
erase byt
readfile=s
end function
)
示例代码如下:
Option Explicit
Public filName As String
Public intTime1 As Integer
Public intTime2 As Integer
Private Sub Command1_Click()
On Error GoTo err1
If intTime1 <> 0 Then
Text1.Text = ""
Text2.Text = ""
End If
cd1.Filter = "文本文件|*.txt"
cd1.DialogTitle = "请选择要打开的BIG5码文件"
'cd1.Left = Form1.Width / 2
'cd1.Top = Form1.Height / 2
cd1.ShowOpen
filName = cd1.FileName
Dim strWord As String
'Dim strWord2 As String
'MsgBox filName
Open filName For Input As #1
Do While Not EOF(1) ' 循环至文件尾。
Line Input #1, strWord ' 读入一行数据并将其赋予某变量。
Text1.Text = Text1.Text + strWord + vbCrLf
Loop
Close #1
Text2.Text = Form1.Big2GB1.BigToGB(Text1.Text)
'save
cd1.Filter = "文本文件|*.txt"
cd1.DialogTitle = "请输入要保存的GB码文件名"
'cd1.Left = Form1.Width / 2
'cd1.Top = Form1.Height / 2
cd1.ShowSave
filName = cd1.FileName
Open filName For Output As #1
Write #1, Text2.Text
Close #1
intTime1 = 1
err1:
End Sub
Private Sub Command2_Click()
On Error GoTo err1
If intTime2 <> 0 Then
Text1.Text = ""
Text2.Text = ""
End If
cd1.Filter = "文本文件|*.txt"
cd1.DialogTitle = "请选择要打开的GB码文件"
cd1.ShowOpen
filName = cd1.FileName
Dim strWord As String
'Dim strWord2 As String
'MsgBox filName
Open filName For Input As #1
Do While Not EOF(1) ' 循环至文件尾。
Line Input #1, strWord ' 读入一行数据并将其赋予某变量。
Text2.Text = Text2.Text + strWord + vbCrLf
Loop
Close #1
Text1.Text = Form1.Big2GB1.GBToBig(Text2.Text)
'save
cd1.Filter = "文本文件|*.txt"
cd1.DialogTitle = "请输入要保存的BIG5码文件名"
cd1.ShowSave
filName = cd1.FileName
Open filName For Output As #1
Write #1, Text1.Text
Close #1
intTime2 = 1
err1:
End Sub
Private Sub Command3_Click()
Unload Me
End
End Sub
Private Sub Form_Load()
ChDrive App.Path
ChDir App.Path
Form1.Picture = LoadPicture("")
End Sub