Hi all,
Going mad not being able to figure this out.
I have an application that uses the following code to write a number of user inputed variables to a text file on a seperate line per variable..
What I can figure out despite hours of googling, is how to reverse the process, and load the data from the text file to re-populate the variables.
Private Sub CmdSave_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CmdSave.Click
'Check if file exists and warn of overwriting.
Dim Response
If File.Exists("c:\EveOreData.csv") Then
Response = MsgBox("Overwrite Existing Save File?", MsgBoxStyle.YesNo, "Overwrite?")
If Response = vbNo Then
Exit Sub
End If
End If
Dim MiningSkill, ExhumerSkill, AstrogeologySkill, MiningBargeSkill, IceHarvesting, MiningDroneOperation, DroneInterfacing As Integer
Dim MyCSVWriter As System.IO.StreamWriter
Dim MyFileName As String
Dim MyNewLine As String
'get data to save
MiningSkill = CboMining.Text
ExhumerSkill = CboExhumers.Text
AstrogeologySkill = CboAstrogeology.Text
MiningBargeSkill = CboMiningbarge.Text
IceHarvesting = CboIceharvesting.Text
MiningDroneOperation = CboMDOS.Text
DroneInterfacing = CboDIS.Text
'Create and write data
MyFileName = "c:\EveOreData.csv"
MyCSVWriter = My.Computer.FileSystem.OpenTextFileWriter(MyFileName, False)
'Write each variable to a new line
MyNewLine = MiningSkill
MyCSVWriter.WriteLine(MyNewLine)
MyNewLine = ExhumerSkill
MyCSVWriter.WriteLine(MyNewLine)
MyNewLine = AstrogeologySkill
MyCSVWriter.WriteLine(MyNewLine)
MyNewLine = MiningBargeSkill
MyCSVWriter.WriteLine(MyNewLine)
MyNewLine = IceHarvesting
MyCSVWriter.WriteLine(MyNewLine)
MyNewLine = MiningDroneOperation
MyCSVWriter.WriteLine(MyNewLine)
MyNewLine = DroneInterfacing
MyCSVWriter.WriteLine(MyNewLine)
MyCSVWriter.Close()
'Give Save Confirmation
Dim msg = "Data saved to File - C:\EveOreData.csv"
Dim title = "Data Saved"
Dim style = MsgBoxStyle.OkOnly
MsgBox(msg, style, title)
End Sub
If anyone can point me in teh right direction I'd be very grateful !!!!
Thanks in advance,
Peter