im having issues with looping. This program needs the user to enter the upc and quantity then store the information then loop through the entered upc's and display the information. all i can get it to do is repeat the first entry 5 times. any advice would be helpful. I have included the entire code just because i'm not certain which part to post
Public Class SalesForm
'Declare Module level variables & Hold UPC Code and total for 5 UPC's
Private ArrayUPC(0 To 4) As String
Private UPCPrice(0 To 4) As Decimal
Private UPCDesc(0 To 4) As String
Private UPCCode(0 To 4) As String
Private PriceTotalDecimal(0 To 4) As Decimal
Private GrandTotalDecimal(0 To 4) As Decimal
Private ItemQuantityInteger(0 To 4) As Integer
Private ItemDescString(0 To 4) As String
Private IndexInteger As Integer = 0
Private Sub SalesForm_Load(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles MyBase.Load
'Initialize UPC Codes
ArrayUPC(0) = "0921115150"
ArrayUPC(1) = "2221001501"
ArrayUPC(2) = "6652300415"
ArrayUPC(3) = "0255541028"
ArrayUPC(4) = "0921115141"
UPCDesc(0) = "Dark Chocolate"
UPCDesc(1) = "Mint Meltaways"
UPCDesc(2) = "Chocolate Covered Cherries"
UPCDesc(3) = "Malted Milk Balls"
UPCDesc(4) = "chocolate Covered Raisins"
UPCPrice(0) = 13.75D
UPCPrice(1) = 14.1D
UPCPrice(2) = 8.9D
UPCPrice(3) = 5.99D
UPCPrice(4) = 7.25D
End Sub
Private Sub AddButton_Click(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles AddButton.Click
'accumulate orders by upc
Dim OrderedInteger As Integer
Dim FoundBoolean As Boolean = False
' Lookup Input UPC Code to find subscript
Try
Do Until FoundBoolean Or IndexInteger > 4
If UPCTextBox.Text = ArrayUPC(IndexInteger) Then
'add order to correct total
OrderedInteger = Integer.Parse(QuantityTextBox.Text)
UPCCode(IndexInteger) += ArrayUPC(IndexInteger)
ItemQuantityInteger(IndexInteger) += OrderedInteger
PriceTotalDecimal(IndexInteger) += OrderedInteger * UPCPrice(IndexInteger)
GrandTotalDecimal(IndexInteger) += PriceTotalDecimal(IndexInteger)
ItemDescString(IndexInteger) = UPCDesc(IndexInteger)
FoundBoolean = True
QuantityTextBox.Clear()
With UPCTextBox
.Focus()
.Clear()
End With
Else
IndexInteger += 1
End If
Loop
If Not FoundBoolean Then
MessageBox.Show("Enter a valid UPC", "Data Entry Error", _
MessageBoxButtons.OK, MessageBoxIcon.Exclamation)
With UPCTextBox
.Focus()
.SelectAll()
End With
End If
Catch QuantityException As FormatException
MessageBox.Show("Please enter the amount ordered in numeric form.", "Data Entry Error", _
MessageBoxButtons.OK, MessageBoxIcon.Exclamation)
With QuantityTextBox
.Focus()
.SelectAll()
End With
End Try
End Sub
Private Sub ExitButton_Click(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles ExitButton.Click
'close application
Dim ResponseDialogResult As DialogResult
'double check to make sure to exit
ResponseDialogResult = MessageBox.Show("Do you want to exit the program?", "Application Shut down", _
MessageBoxButtons.YesNo, MessageBoxIcon.Question)
If ResponseDialogResult = DialogResult.Yes Then
Me.Close()
End If
End Sub
Private Sub PrintButton_Click(ByVal sender As System.Object, _
ByVal e As System.EventArgs) _
Handles PrintButton.Click
'print the report using print preview
PrintPreviewDialog1.Document = PrintDocument1
PrintPreviewDialog1.ShowDialog()
End Sub
Private Sub PrintDocument1_PrintPage(ByVal sender As System.Object, _
ByVal e As System.Drawing.Printing.PrintPageEventArgs) _
Handles PrintDocument1.PrintPage
'Handle print and print preview
Dim PrintFont As New Font("Arial", 12)
Dim HeadingFont As New Font("Arial", 14, FontStyle.Bold)
Dim LineHeightSingle As Single = PrintFont.GetHeight + 2
Dim Column1HorizontalLocationSingle As Single = e.MarginBounds.Left
Dim VerticalPrintlocationSingle As Single = e.MarginBounds.Top
Dim Column2HorizontalLocationsingle As Single = 250
Dim Column3HorizontalLocationSingle As Single = 400
Dim Column4HorizontalLocationSingle As Single = 500
Dim Column5HorizontallocationSingle As Single = 600
Dim PrintLineString As String
Dim FormattedQuantityString As String
Dim LoopInteger As Integer
Dim FoundBoolean As Boolean = False
'Set up and Display Headings
PrintLineString = "CandyCo Sales Report"
e.Graphics.DrawString(PrintLineString, HeadingFont, _
Brushes.Black, Column2HorizontalLocationsingle, _
VerticalPrintlocationSingle)
PrintLineString = "Programmed by Leo Lynch"
VerticalPrintlocationSingle += LineHeightSingle
e.Graphics.DrawString(PrintLineString, PrintFont, _
Brushes.Black, Column2HorizontalLocationsingle, _
VerticalPrintlocationSingle)
VerticalPrintlocationSingle += LineHeightSingle * 2
'Set Up Tables
e.Graphics.DrawString("UPC Code", PrintFont, Brushes.Black, _
Column1HorizontalLocationSingle, VerticalPrintlocationSingle)
e.Graphics.DrawString("Description", PrintFont, Brushes.Black, _
Column2HorizontalLocationsingle, VerticalPrintlocationSingle)
e.Graphics.DrawString("Price", PrintFont, Brushes.Black, _
Column3HorizontalLocationSingle, VerticalPrintlocationSingle)
e.Graphics.DrawString("Quantity", PrintFont, Brushes.Black, _
Column4HorizontalLocationSingle, VerticalPrintlocationSingle)
e.Graphics.DrawString("Total Cost", PrintFont, Brushes.Black, _
Column5HorizontallocationSingle, VerticalPrintlocationSingle)
VerticalPrintlocationSingle += LineHeightSingle * 2
FormattedQuantityString = Integer.Parse(ItemQuantityInteger(IndexInteger))
IndexInteger = 0
LoopInteger = 0
'Loop through the orders and UPC's
For LoopInteger = 0 To 4
If FormattedQuantityString <> "" Then
'UPC Code
e.Graphics.DrawString(UPCCode(IndexInteger), PrintFont, Brushes.Black, _
Column1HorizontalLocationSingle, VerticalPrintlocationSingle)
'item description
e.Graphics.DrawString(UPCDesc(IndexInteger), PrintFont, Brushes.Black, _
Column2HorizontalLocationsingle, VerticalPrintlocationSingle)
'UPC Price
e.Graphics.DrawString(UPCPrice(IndexInteger).ToString("C"), PrintFont, Brushes.Black, _
Column3HorizontalLocationSingle, VerticalPrintlocationSingle)
'Amount Ordered
e.Graphics.DrawString(ItemQuantityInteger(IndexInteger), PrintFont, Brushes.Black, _
Column4HorizontalLocationSingle, VerticalPrintlocationSingle)
'Total Price of item
e.Graphics.DrawString(PriceTotalDecimal(IndexInteger).ToString("C"), PrintFont, Brushes.Black, _
Column5HorizontallocationSingle, VerticalPrintlocationSingle)
VerticalPrintlocationSingle += LineHeightSingle * 2
Else
IndexInteger += 1
End If
Next LoopInteger
'Grand total
e.Graphics.DrawString("Grand Total Price of Items Ordered", PrintFont, Brushes.Black, _
Column1HorizontalLocationSingle, VerticalPrintlocationSingle)
e.Graphics.DrawString(GrandTotalDecimal(IndexInteger).ToString("C"), PrintFont, Brushes.Green, _
Column5HorizontallocationSingle, VerticalPrintlocationSingle)
End Sub
End Class