Answer the question
In order to leave comments, you need to log in
Split data into multiple files?
A number is given. It is necessary to write data to the file in the order of integers from 1 to a given number, if there is a lot of data, then you can write it to different files
, for example. It is given to write all numbers from 1 to 999 into four different files. Since there are 4 files, I will write 999/4 = 249 values to each file.
Here is the code
Private Sub Command1_Click()
Dim MyFile As Long
MyFile = FreeFile
file_kolvo = Int(Val(Text2.Text))
txt = Int(Val(Text1.Text))
If Check1.Value = 0 Then
file_kolvo = 0
For i = 1 To txt
Open ("C:\TEST.txt") For Append As #MyFile
Print #MyFile, i
Close #MyFile
If i = txt Then
MsgBox ("Все цифры в файле C:\TEST.txt")
End If
Next
Else
n = 1
z = 0
chislo_v_faile = Int(txt / file_kolvo)
For iter_file_kolvo = 1 To file_kolvo
z = z + (chislo_v_faile)
For i = n To z
Open ("C:\TEST" & iter_file_kolvo & ".txt") For Append As #MyFile
Print #MyFile, i
Close #MyFile
Next i
n = n + (chislo_v_faile)
Next iter_file_kolvo
End If
End Sub
Answer the question
In order to leave comments, you need to log in
chislo_v_faile = Int((txt+file_kolvo) / file_kolvo)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question