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

help! I need some help with my array!!

$
0
0
I'm working on a project and I need it to be able to subtract the quantity ordered from the inventory presented in the array. I also need to be able to not allow the quantity ordered to ever exceed the inventory level in the array. If anyone could offer me some assistance I would greatly appreciate it!

here's what I have so far... I know I may not be doing this the easy way but I'm kinda new at this..

Public Class Form1
Dim catno(intMAX_Subscript) As String
Dim desc(intMAX_Subscript) As String
Dim price(intMAX_Subscript) As Single
Dim quantity(intMAX_Subscript) As Integer
Dim unitsReq(intMAX_Subscript) As Integer
Const intMAX_Subscript As Integer = 9
Dim subtotal(intMAX_Subscript) As Single
Dim total As Single
Dim shipping As Single
Dim grandtotal As Single


Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
initArrays()
End Sub
Private Sub initArrays()
catno(0) = "A20gaw"
desc(0) = "golden apples-WA"
price(0) = ".83"
quantity(0) = 388

catno(1) = "A21ham"
desc(1) = "HoneyCrisp Aplles-MN"
price(1) = "3.13"
quantity(1) = 224

catno(2) = "B28gbh"
desc(2) = "Green Banana-HI"
price(2) = ".25"
quantity(2) = 2170

catno(3) = "B67vba"
desc(3) = "Vaccinium Blueberries-AL"
price(3) = ".10"
quantity(3) = 3000

catno(4) = "G17rgf"
desc(4) = "Ruby Red Grapefruit-FL"
price(4) = "1.36"
quantity(4) = 605

catno(5) = "M45pmm"
desc(5) = "Pulp Mango-MX"
price(5) = "1.11"
quantity(5) = 315

catno(6) = "O17nof"
desc(6) = "Navel Orange-FL"
price(6) = ".84"
quantity(6) = 823

catno(7) = "P27gph"
desc(7) = "Golden Pinapple-HI"
price(7) = "2.45"
quantity(7) = 319

catno(8) = "S49rsc"
desc(8) = "Red Strawberry-CA"
price(8) = "2.99"
quantity(8) = 800

catno(9) = "W09swi"
desc(9) = "Seedless Watermelon-IN"
price(9) = "1.70"
quantity(9) = 277
End Sub


Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim intcount As Integer = 0
Do While intcount <= intMAX_Subscript
Try
unitsReq(intcount) = CInt(
InputBox("enter the amount of " & catno(intcount) & " you would like to purchase"))
intcount += 1


Catch
MessageBox.Show("enter a valid amount")


Return


End Try

Loop


For intcount = 0 To intMAX_Subscript


ListBox1.Items.Add("Catalog number: " & catno(intcount))
ListBox1.Items.Add("Description: " & desc(intcount))
ListBox1.Items.Add("Price: " & price(intcount).ToString("c"))
ListBox1.Items.Add("Quantity: " & unitsReq(intcount))
ListBox1.Items.Add("Subtotal per Item: " & (price(intcount) * unitsReq(intcount)).ToString("c"))

subtotal(0) = price(0) * unitsReq(0)
subtotal(1) = price(1) * unitsReq(1)
subtotal(2) = price(2) * unitsReq(2)
subtotal(3) = price(3) * unitsReq(3)
subtotal(4) = price(4) * unitsReq(4)
subtotal(5) = price(5) * unitsReq(5)
subtotal(6) = price(6) * unitsReq(6)
subtotal(7) = price(7) * unitsReq(7)
subtotal(8) = price(8) * unitsReq(8)
subtotal(9) = price(9) * unitsReq(9)

total = subtotal(0) + subtotal(1) + subtotal(2) + subtotal(3) + subtotal(4) + subtotal(5) + subtotal(6) + subtotal(7) + subtotal(8) + subtotal(9)


If total < "100" Then
shipping = 4.99
Else
If total >= "100" And total < "250" Then
shipping = 3.49
Else
If total >= "250" And total < "500" Then
shipping = 2.99
Else
If total >= "500" Then
shipping = 0
End If
End If
End If
End If

If CheckBox1.Checked = True Then
grandtotal = total + (total * 0.08) + shipping
Else
grandtotal = total + shipping
End If

TextBox1.Text = grandtotal.ToString("c")
Next
If unitsReq(0) > 1 Then

End If

End Sub


End Class

...Thanks for the help in advance!!

Viewing all articles
Browse latest Browse all 27416

Trending Articles



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