How to create txt file

后端 未结 2 1706
北荒
北荒 2021-01-01 02:27

I have to create a txt file so with some large content in VB6. Can anybody help me out on this and please tell me the references also.

2条回答
  •  盖世英雄少女心
    2021-01-01 03:14

    how large?

    to keep it simple:

    '1 form with:
    '  1 textbox: name=Text1
    '  1 command button: name=Command1
    Option Explicit
    
    Private Sub Command1_Click()
      Dim intFile As Integer
      Dim strFile As String
      strFile = "c:\temp\file.txt" 'the file you want to save to
      intFile = FreeFile
      Open strFile For Output As #intFile
        Print #intFile, Text1.Text 'the data you want to save
      Close #intFile
    End Sub
    

    this will replace the file each time you click the command button, if you want to add to the file then you can open "for append" instead of "for output"

    reference

提交回复
热议问题