VB读写

前端之家收集整理的这篇文章主要介绍了VB读写前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

lof返回的是字节数 而VB的字符串是以一个UniCode字符作为单位 读取: Dim TempFile As Long Dim LoadBytes() As Byte TempFile=FreeFile Open 文件名 For Binary As #TempFile Redim LoadBytes(1 To Lof(TempFile)) As Byte Get #TempFile,LoadBytes Close TempFile Text1.Text=StrConv(LoadBytes,vbUniCode) 写入: Dim TempFile As Long Dim SaveBytes() As Byte SaveBytes=StrConv(Text1.Text,vbFromUniCode) TempFile=FreeFile Open 文件名 For Binary As #TempFile Put #TempFile,SaveBytes Close TempFile 复制文件: Public Sub MyCopy(SFile As String,DFile As String) Dim TempFile As Integer Dim TempBytes() As Byte Dim FileLen As Long TempFile = FreeFile Open SFile For Binary As #TempFile FileLen = LOF(TempFile) ReDim TempBytes(1 To FileLen) Get #TempFile,TempBytes Close #TempFile Open DFile For Binary As #TempFile Put #TempFile,TempBytes Close #TempFile End Sub

猜你在找的VB相关文章