Hi guys,i'm currently writing an application that collects data from users through the use of textboxes.How do i save the data as a CSV file?
Please help in anyway u can,i'm in real need of some help here.
Printable View
Hi guys,i'm currently writing an application that collects data from users through the use of textboxes.How do i save the data as a CSV file?
Please help in anyway u can,i'm in real need of some help here.
This code goes through all textboxes on the form and adds the text from each textbox to a line to be wrote to file. the line is appended to any previous lines in the csv file
VB Code:
Dim l_sWriter As New StreamWriter("myfile.csv", TRUE) Dim l_csvLine As String Try Dim l_ctrl As Control For each l_ctrl In me.Controls If Typeof(l_ctrl) is textbox Then l_csvLine &= l_ctrl.text & "," End IF Next 'Remove the trailing comma l_csvLine = Mid(l_csvLine, 1, l_csvLine.Length - 1) 'Write the data to the file l_sWriter.WriteLine(l_csvLine) l_csvLine = "" End While Catch ex As IOException MsgBox(ex.Message, MsgBoxStyle.Information, "ManoWave") Finally l_sWriter.Close() End Try
Thank you for those lines of codes.I'll go work on it !!