VB6文件读写

VB6文件读写,第1张

Private Sub command1_click()

If Dir(App.Path & "\int\1.txt") = "" Then

MkDir App.Path & "\int"

End

Else

Open App.Path & "\int\1.txt" For Input As #1

Line Input #1, textline

Close #1

End If

If textline = "OK" Then Form2.Show

End Sub

要求窗体1上要有一个按钮 并创建窗体2 代码要先编译后运行

文件

 Dim s As String

   Dim filename As String

   filename = shuxiang & xingzuo & ".txt"

Open filename For Input As #1

Do While Not EOF(1)

Line Input #1, s

Print s

Loop

Close #1

追加写文件

Dim i As Integer, n As Integer, a(6) As Integer

n = 6

Open "D:\1122.txt" For Append As #1

Randomize

For i = 1 To n

    a(i) = Int(Rnd * 1000 + 1)

    Print #1, a(i)

  Next i

Close #1

覆盖写文件

Dim i As Integer, n As Integer, a(6) As Integer

n = 6

Open "D:\1122.txt" For output As #1

Randomize

For i = 1 To n

    a(i) = Int(Rnd * 1000 + 1)

    Print #1, a(i)

  Next i

Close #1


欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/tougao/8072676.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2023-04-13
下一篇 2023-04-13

发表评论

登录后才能评论

评论列表(0条)

保存