Private Sub btncalculate_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btncalculate.Click
Call change()
'Aim: Save files from list
'Declare Variables
Dim sFilename As String
Dim sr_Marksfile As StreamReader
Dim icounter As Integer
Dim sLine As String
Dim iNumRecords As Integer
Dim iMaxProducts As Integer = 10
Dim sDelimeter As String
Dim sStrName As String = Replace(Today.ToShortDateString, "/", "_")
Dim iorderno As Integer
'Store path and name of file to open & read from
sFilename = Application.StartupPath & "\" & sStrName & ".txt"
'Write contents in listbox to textfile
Dim sw_file As StreamWriter
iNumRecords = Me.lstid.Items.Count
sDelimeter = ","
sw_file = New StreamWriter(sFilename, True)
For icounter = 0 To iNumRecords - 1
sLine = Me.lblorderno.Text & sDelimeter & Me.lstid.Items(icounter) & sDelimeter & _
Me.lstdescription.Items(icounter) & sDelimeter & Me.lstquantity.Items(icounter) & _
sDelimeter & Me.lstprice.Items(icounter) & sDelimeter & Me.lsttotal.Items(icounter)
sw_file.WriteLine(sLine)
Next
sw_file.Close()
iorderno = iorderno + 1
Me.lblorderno.Text = iorderno
End Sub