VB中,我赋值给一个二维数组,想把这个数组保存到txt中,然后再从这个TXT文件中把读取数据,再赋给二维数组 15
VB中,我赋值给一个二维数组,想把这个数组保存到txt中,然后再从这个TXT文件中读取数据,再赋给二维数组,哪位大侠能帮我一下呀,急用,给我一个完整的代码吧,高分求。。。...
VB中,我赋值给一个二维数组,想把这个数组保存到txt中,然后再从这个TXT文件中读取数据,再赋给二维数组,哪位大侠能帮我一下呀,急用,给我一个完整的代码吧,高分求。。。。。代码能用的话,可以追加
展开
展开全部
Dim a(1 To 10) As Integer
Private Sub Cmd1_Click()
Dim i As Integer
Text1.Text = ""
Open "in.txt" For Input As #1
For i = 1 To 10
Input #1, a(i)
Text1.Text = Text1.Text & a(i) & Space(5)
Next i
Close #1
End Sub
Private Sub Cmd2_Click()
Dim i As Integer, j As Integer, temp As Integer
For j = 1 To 10
For i = 1 To j - 1
If a(i) > a(j) Then temp = a(i): a(i) = a(j): a(j) = temp
Next i
Next j
Text1.Text = ""
For i = 1 To 10
for j=1 to 10
Text1.Text = Text1.Text & a(i,j) & Space(5)
next j
Next i
Open "result.txt" For Output As #2
For i = 1 To 10
for j=1 to 10
Print #2, a(i,j)
next j
print
Next i
Close #2
End Sub
上面这个代码读和写都有。上面是读取,下面是写入。
Private Sub Cmd1_Click()
Dim i As Integer
Text1.Text = ""
Open "in.txt" For Input As #1
For i = 1 To 10
Input #1, a(i)
Text1.Text = Text1.Text & a(i) & Space(5)
Next i
Close #1
End Sub
Private Sub Cmd2_Click()
Dim i As Integer, j As Integer, temp As Integer
For j = 1 To 10
For i = 1 To j - 1
If a(i) > a(j) Then temp = a(i): a(i) = a(j): a(j) = temp
Next i
Next j
Text1.Text = ""
For i = 1 To 10
for j=1 to 10
Text1.Text = Text1.Text & a(i,j) & Space(5)
next j
Next i
Open "result.txt" For Output As #2
For i = 1 To 10
for j=1 to 10
Print #2, a(i,j)
next j
Next i
Close #2
End Sub
上面这个代码读和写都有。上面是读取,下面是写入。
追问
你那个写入怎么是一维的,我需要二维的呀 而且希望两个是有联系的 你这个好像是独立的
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询