加载中…
个人资料
  • 博客等级:
  • 博客积分:
  • 博客访问:
  • 关注人气:
  • 获赠金笔:0支
  • 赠出金笔:0支
  • 荣誉徽章:
正文 字体大小:

VB6最简单文件读写示例

(2022-03-28 17:00:08)
分类: VB
VB6最简单文件读写示例
━━━━━━━━━━━━━━━━━━━━━━━━━
Private Sub Command1_Click()    '读入文件
    
Dim As String
    Open 
"c:\1.txtFor Input As #1
    Do While Not EOF(1)
        
Input #1, a
        Text2.Text Text2.Text vbCrLf a
    Loop
    Close #
1
End Sub

Private Sub 
Command2_Click()    '写出文件
    
Open "c:\2.txtFor Output As #1
    Print #1, Text1.Text
    Close #1
End Sub
━━━━━━━━━━━━━━━━━━━━━━━━━
Private Sub Command2_Click()    '以二进制方式读入文本文件
    
Dim Bytes() As Byte
    
Dim Txt As String
    Open 
"c:\1.txtFor Binary As #1
    ReDim Bytes(To LOF(1)) As Byte
    
Get #1, Bytes
    Close #1
    Txt StrConv(Bytes, vbUnicode)
    
Text1.Text Txt
End Sub

Private Sub 
Command3_Click()    '以二进制方式写出文本文件
    
Dim Bytes() As Byte
    
Bytes StrConv(Text1.Text, vbFromUnicode)
    
Open "c:\3.txtFor Binary As #1
    Put #1, Bytes
    Close #1
End Sub

0

阅读 收藏 喜欢 打印举报/Report
  

新浪BLOG意见反馈留言板 欢迎批评指正

新浪简介 | About Sina | 广告服务 | 联系我们 | 招聘信息 | 网站律师 | SINA English | 产品答疑

新浪公司 版权所有