我正在尝试编辑" AM830.txt"使用他们输入全局******变量的用户信息
Public DestinationTick As String
Public PlaneTick As String
Public TimeTick As String
Public NameTick As String
Public DayTick As String
Public Stockitems() As String = IO.File.ReadAllLines("AM830.csv")
Public SortedStock(Stockitems.Length - 1)
Public Stocktypes(Stockitems.Length - 1) As Flight
Public Structure Flight
Public Destination As String
Public Plane As String
Public Time As String
Public Name As String
Public Day As String
Public Address As String
End Structure
''' when they press the button names P1A1
System.IO.File.WriteAllText("AM830.csv", "")
If P1A1.BackColor = Color.Red Then
Stocktypes(0).Destination = GlobalDestination
Stocktypes(0).Plane = GlobalPlane
Stocktypes(0).Time = GLobalTime
Stocktypes(0).Name = GlobalName
Stocktypes(0).Day = GlobalDay
Stocktypes(0).Address = GlobalAddress
P1A1.Enabled = False
End If
For Each item In Stocktypes
My.Computer.FileSystem.WriteAllText("AM830.txt", item.Destination & "," & item.Plane & "," & item.Time & "," & item.Name & "," & item.Day & "," & item.Address)
Next
在" My.Computer.Filesystem.WriteAllTest(...........)中我收到错误"重载决议失败,因为没有可访问的' WriteAllText&#39 ;接受这个数量的论点"我不知道这甚至意味着什么?
我是VB的新手,这是我第一个使用文件的程序,很抱歉,如果这是一个愚蠢的问题
答案 0 :(得分:1)
My.Computer.FileSystem.WriteAllText至少需要3个参数。您必须添加True或False以指示是否要将文本添加到文件中的现有文本或覆盖文件中的所有内容。正确的方法是:
For Each item In Stocktypes
My.Computer.FileSystem.WriteAllText("AM830.txt", item.Destination & "," & item.Plane & "," & item.Time & "," & item.Name & "," & item.Day & "," & item.Address,True)
Next