代码如下:
Public Class Form1
...
Private Sub Timer1_Tick(sender As Object, e As EventArgs) Handles Timer1.Tick
Dim i As Integer
For i = 0 To 29
If p1(i).sn = TextBox1.Text Then txtWR.WriteToTxt(i)
p1(i).go(i)
Next
End Sub
...
End Class
Imports System.IO
Public Class txtData
Private SW As New StreamWriter("E:\aaa.txt", True)
...
Public Sub WriteToTxt(index As Integer)
With Form1.p1(index)
SW.WriteLine(.Location.X)
SW.WriteLine(.Location.Y)
End With
End Sub
....
End Class
以上是涉及到的代码,运行无错,但是aaa.txt是空的。没有任何数据?请指点一下。
------解决思路----------------------
SW.Flush()
SW.Close()
SW.Dispose()
------解决思路----------------------
流关闭了吗?