以下是用VB编写的程序:

'生成100个商场的序号(1到500之间) Dim rnd As New Random Dim malls(99) As Integer For i As Integer = 0 To 99 malls(i) = rnd.Next(1, 501) Next

'将商场序号写入文本文件1 Dim file1 As System.IO.StreamWriter file1 = My.Computer.FileSystem.OpenTextFileWriter("file1.txt", False) For i As Integer = 0 To 99 file1.WriteLine(malls(i)) Next file1.Close()

'生成每个商场一年4个随机数 Dim sales(399) As Integer Dim index As Integer = 0 For i As Integer = 0 To 99 For j As Integer = 0 To 3 sales(index) = rnd.Next(1, 1001) index += 1 Next Next

'将销售数据写入文本文件2 Dim file2 As System.IO.StreamWriter file2 = My.Computer.FileSystem.OpenTextFileWriter("file2.txt", False) For i As Integer = 0 To 399 file2.WriteLine(sales(i)) Next file2.Close()

'将文本文件1和2合并到文本文件3 Dim file3 As System.IO.StreamWriter file3 = My.Computer.FileSystem.OpenTextFileWriter("file3.txt", False) Dim lines1() As String = System.IO.File.ReadAllLines("file1.txt") For Each line In lines1 file3.WriteLine(line) Next Dim lines2() As String = System.IO.File.ReadAllLines("file2.txt") For Each line In lines2 file3.WriteLine(line) Next file3.Close()

'复制程序 My.Computer.FileSystem.CopyFile("path\to\source\program.exe", "path\to\destination\program.exe", True


原文地址: https://www.cveoy.top/t/topic/eAqw 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录