|
-
Apr 12th, 2004, 08:52 PM
#1
Thread Starter
New Member
question
i have this code:
While (discountsfile.Peek() > -1)
disc = discountsfile.ReadLine()
pos = InStr(disc, " ")
discamounts = CDbl(Microsoft.VisualBasic.Left(disc, pos - 1))
saleamounts = CInt(Mid(disc, pos + 1))
totalPrice = totalPrice - (totalPrice * (saleamounts / 100))
If totalPrice >= discamounts Then
txtdiscount.Text = Format(totalPrice, "Standard")
Exit While
End If
End While
txtPST.Text = Format(PST, "Standard")
GST = Math.Round(totalPrice * GSTrate, 2)
txtGST.Text = Format(GST, "Standard")
txtTotalAmount.Text = Format(totalPrice + PST + GST, "Standard")
when i click the total button, the pst, gst, price, and total amount appear in different text boxes.
the problem is that if i click the total button again, it will accumulate in price.
the exit while doesn't work.
how can i make it so that the price, pst, gst, and total text box amounts don't keep accumulating when i click the button?
-
Apr 12th, 2004, 09:26 PM
#2
You could try Exit Sub (or Function if its in a function)...
Phreak
Visual Studio 6, Visual Studio.NET 2005, MASM
-
Apr 12th, 2004, 11:44 PM
#3
Sleep mode
One way would be like this (if I really understand your problem) :
Declare a private field as boolean . When you're done with your iteration set this variable to true , something like this :
VB Code:
'Class member variable
Private bool As Boolean =False
If Not bool Then
While (discountsfile.Peek() > -1)
disc = discountsfile.ReadLine()
pos = InStr(disc, " ")
discamounts = CDbl(Microsoft.VisualBasic.Left(disc, pos - 1))
saleamounts = CInt(Mid(disc, pos + 1))
totalPrice = totalPrice - (totalPrice * (saleamounts / 100))
If totalPrice >= discamounts Then
txtdiscount.Text = Format(totalPrice, "Standard")
bool=True
Exit While
End If
End While
txtPST.Text = Format(PST, "Standard")
bool=True
GST = Math.Round(totalPrice * GSTrate, 2)
txtGST.Text = Format(GST, "Standard")
txtTotalAmount.Text = Format(totalPrice + PST + GST, "Standard")
End If
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|