Calculating change

tk.unlimited

Active member
Joined
Apr 2, 2005
Messages
27
Programming Experience
1-3
Order Number Incrementation

My problem is still my order no. Each time i process an order i want the orderno. to increment by one and for some reason += 1 doesnt work.. only just adds one.. and then doesnt add nething else
 
Last edited:
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

 
You might have a to declare iorderno to 0 before it will work. This might be correct but I don't think you can add 1 to nothing. You might have to declare iroderno outside of the button click event.
 
Thanks guys Kulrom by putting it in the FOR Loop itll count the items in the listbox.. But thanks for the suggestion.. Any idea how i would keep the orderno value in the label soo when i open it next time the value is still there??
 
wait a minute ... i missed your point ... that's obviously ;)
but we shall improve that ... just please explain your idea ... what are you trying to accomplish there? probably you need to write that in datasource like text file or xml ... as otherwise you have no option to keep value if you close the application.

waiting for your feedback ... Cheers ;)

P.s. you say when i open next time ... open only form (without closing entire app) or open application and form as well?
 
Last edited:
Back
Top