Welcome to Dream.In.Code
Become a VB Expert!

Join 149,486 VB Programmers for FREE! Get instant access to thousands of VB experts, tutorials, code snippets, and more! There are 1,347 people online right now. Registration is fast and FREE... Join Now!




For...Each...Next statement

 
Reply to this topicStart new topic

For...Each...Next statement

Persistant
25 Apr, 2007 - 01:55 PM
Post #1

New D.I.C Head
*

Joined: 5 Apr, 2007
Posts: 28


My Contributions
Can someone Please take a look at this and tell me what I need to do to get the calculations for Total on Sale and Total Regular Price? I have tried every different scenario I can think of and at one point they were reversed, so I thought that I could just reverse the items after the = sign, but Oh No that would have been too simple. : )

Private Sub btnTotalSales_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnTotalSales.Click
'Read each item in the lstTodaysSales list box, determine
' the amount in the second column, add the amount to the
' appropriate totals, and then display the totals.
Dim intIndex, intListCount As Integer
Dim sngTotalSales As Single = 0
Dim sngTotalOnSale As Single = 0
Dim sngTotalRegularPrice As Single = 0
Dim sngItemSales As Single
Dim strResults As String, strItemSales As String
intListCount = Convert.ToInt32(lstTodaysSales.Items.Count)
Dim lviTodaysSales As ListViewItem
For Each lviTodaysSales In lstTodaysSales.Items
strItemSales = lviTodaysSales.SubItems(1).Text
strItemSales = strItemSales.Replace("$", "0")
sngItemSales = Convert.ToSingle(strItemSales)
sngTotalSales = sngTotalSales + sngItemSales
sngTotalOnSale = sngTotalSales - sngItemSales
sngTotalRegularPrice = sngItemSales
sngTotalOnSale = sngTotalSales - sngTotalRegularPrice
sngTotalRegularPrice = sngTotalSales - sngTotalOnSale

Next
strResults = "Total sales today: " & Format$(sngTotalSales, "Currency") & ControlChars.NewLine
strResults &= "Total sales for items on sale: " & Format$(sngTotalOnSale, "Currency") & ControlChars.NewLine
strResults &= "Total sales for items not on sale: " & Format$(sngTotalRegularPrice, "Currency")
MessageBox.Show(strResults, "Daily Sales Totals")
End Sub

This post has been edited by Persistant: 26 Apr, 2007 - 12:55 AM


Attached File(s)
Attached File  Today_s_Sales_Check.zip ( 97.02k ) Number of downloads: 27
User is offlineProfile CardPM
+Quote Post

KeyWiz
RE: For...Each...Next Statement
25 Apr, 2007 - 07:41 PM
Post #2

D.I.C Regular
Group Icon

Joined: 26 Oct, 2006
Posts: 428


Dream Kudos: 125
My Contributions
Post your code instead of making an unsecure link, and you will get more replies.
User is offlineProfile CardPM
+Quote Post

Persistant
RE: For...Each...Next Statement
26 Apr, 2007 - 12:57 AM
Post #3

New D.I.C Head
*

Joined: 5 Apr, 2007
Posts: 28


My Contributions
QUOTE(KeyWiz @ 25 Apr, 2007 - 08:41 PM) *

Post your code instead of making an unsecure link, and you will get more replies.


Thanks for the input, I wasn't aware of that.
User is offlineProfile CardPM
+Quote Post

Fast ReplyReply to this topicStart new topic
Time is now: 1/7/09 04:51PM

Be Social

Dream.In.Code RSS Feed Dream.In.Code LinkedIn Group Follow Us On Twitter

Live VB Help!

VB Tutorials

Reference Sheets

VB Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month