Quantcast
Channel: VBForums - Visual Basic .NET
Viewing all articles
Browse latest Browse all 27159

Remove Item Remove The Tax----HELP Please

$
0
0
I do not have a code for this, as I have tried and failed many times.
I have a list box, inside the list box are item prices, which a subtotal is gathered and displayed in a separate label, via taxable/nontaxable button
Now, some items are taxable and some are not, based on taxable/non taxable buttons, which in turn display a * when taxed.
Tax is also sumed and displayed in a label.
There is also a remove item button, which removes an item, an in turn should remove the tax associated with selected item.

I do not get this part. i try to selectindex on the number in the list then redo the tax for it.
Then subtract the current total tax from redone item tax then display. It doesn't work.
Any help would be appreciated, i will show you what i have so far, i heard someone even say something about two list boxes but i wouldn't know where to start with that.
please somebody explain this conundrum to me. Thank you for you time....
Also i'm a beginner so i wouldn't know a simpler/more complex/easier method of doing what i have so far but if you explain it to me and if you can show me some linked examples
or some specific tutorials for what i am doing i would truly appreciate it.
also if you have the time i would also need an explanation for a change calculator, google isn't helping, how to do it and how it works if need be i can start another thread
or message me. again thank you.

Dim Counter As Decimal = 0
'Add item price to list and add count to label
Try
ItemPrice = Decimal.Parse(AddTextBox.Text)
ItemListBox.Items.Add(AddTextBox.Text & " " & "*")
ItemCountLabel.Text = ItemListBox.Items.Count.ToString
'add values of list to subtotal GOT THIS CODE FROM SOMEONE ELSE DON'T KNOW HOW IT WORKS
For D As Decimal = 0 To (ItemListBox.Items.Count - 1)
Counter += Val(ItemListBox.Items.Item(D))

Next
SubTotalLabel.Text = Counter.ToString("C")
SubTotal = Decimal.Parse(AddTextBox.Text)
ItemTax = SubTotal * TAXRATE_Decimal
TaxAccum += ItemTax
TaxLabel.Text = TaxAccum.ToString("C")
Total = Counter + TaxAccum
TotalLabel.Text = Total.ToString("C")
AddTextBox.Text = ""
AddTextBox.Focus()

Catch ex As Exception
MessageBox.Show("Price of Items Invalid, Please Enter Valid Price", "Error Found", MessageBoxButtons.OK, MessageBoxIcon.Error)
AddTextBox.SelectAll()
AddTextBox.Focus()
End Try
End Sub
Private Sub RemoveButton_Click(sender As System.Object, e As System.EventArgs) Handles RemoveButton.Click
'delete an item price and update the count
Dim NewSub As Decimal
Dim RemoveTax As Decimal
Dim RemoveItemTax As Decimal
Dim OldTax As Decimal
Dim NewTax As Decimal
If ItemListBox.SelectedIndex > -1 Then
ItemListBox.Items.RemoveAt(ItemListBox.SelectedIndex)
ItemCountLabel.Text = ItemListBox.Items.Count.ToString
Else
MessageBox.Show("Please select an item to delete", "Error Found", MessageBoxButtons.OK, MessageBoxIcon.Error)
End If
'update the count for the subtotal to display new subtotal NOT MY CODE BUT IT WORKS
For D As Decimal = 0 To (ItemListBox.Items.Count - 1)
NewSub += Val(ItemListBox.Items.Item(D))

Next

SubTotalLabel.Text = NewSub.ToString("C")
'try and remove tax associated with item don't know what i'm doing
Try
OldTax = Decimal.Parse(TaxLabel.Text)
RemoveItemTax = Val(ItemListBox.SelectedItem)
RemoveTax = RemoveItemTax * TAXRATE_Decimal
NewTax = OldTax - RemoveTax
TaxLabel.Text = NewTax.ToString("C")
Catch ex As Exception
MessageBox.Show("No Taxes Added Currently", "Error Found", MessageBoxButtons.OK, MessageBoxIcon.Error)
End Try

Viewing all articles
Browse latest Browse all 27159

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>