2 Replies - 837 Views - Last Post: 29 April 2010 - 09:48 AM Rate Topic: -----

#1 kindie  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 25
  • Joined: 28-April 10

Makin an inventory form with parallel arrays

Posted 28 April 2010 - 12:42 PM

Ok I posted earlier about making a form with an inventory menu I realized i wasnt doing it the wrong way I am suppose to use 3 parallel arrays for Inventory Name, Quantity on hand, and Price. And then Im suppose to make four buttons recieve, ship, value, and print and it suppose to update the new quantity on hand text box this homework is really getting on my nerves Ive been tryin to do it for 2 weeks this is what i have

Public Class frmHomework5
    Dim CboInvItems(5) As String
    Dim decPrice(5) As Decimal
    Dim intQty(5) As Integer
    Dim pointer() As Integer





    Private Sub frmHomework5_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

        Dim strFileName As String
        CboInvItems.SelectedItem("Choose one of the following:")
        strFileName = CurDir() & "\City.txt"
        FileOpen(1, strFileName, OpenMode.Input)
        Do Until EOF(1)
            Input(1, strFileName)
            CboInvItems.Items.Add(strFileName)
        Loop
        FileClose()

    End Sub




I was wondering if thats any where near right

Is This A Good Question/Topic? 0
  • +

Replies To: Makin an inventory form with parallel arrays

#2 AdamSpeight2008  Icon User is offline

  • MrCupOfT
  • member icon


Reputation: 1997
  • View blog
  • Posts: 8,808
  • Joined: 29-May 08

Re: Makin an inventory form with parallel arrays

Posted 28 April 2010 - 01:09 PM

using parallel arrays for this, in my opinion is the wrong approach. What you should be doing is using Object Oriented Design, by creating a new class to encapsulate the information.

Each class should only encapsulate the information specific to that object.

A Invoice (Invoice) has many Invoice Items (InvoiceItem)
Each Invoice Item is made up of a Price, Name etc.


Public Class InvoiceItem
  Public Property Name As String
  Public Property Price As Decimal
End Class


Note: Using vb10's auto properties.

and an Invoice is simply a List of Invoice Items, though this could encapsulated into a separate invoice class.
    Dim Invoice As New List(Of InvoiceItem)
    Invoice.Add(New InvoiceItem With {.Name = "Milk", .Price = 1D})
    Invoice.Add(New InvoiceItem With {.Name = "Coffee", .Price = 2.5D})

Was This Post Helpful? 0
  • +
  • -

#3 kindie  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 25
  • Joined: 28-April 10

Re: Makin an inventory form with parallel arrays

Posted 29 April 2010 - 09:48 AM

well i asked the teacher and she said i should use arrays and this is what I got from it


Public Class frmHomework5

    Dim decPrice(5) As Decimal
    Dim intQty(5) As Integer
    Dim pointer(5) As Integer
    Dim intNumPrices As Integer





    Private Sub frmHomework5_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

        Dim strFileName As String
        Dim strName As String
        Dim stringArray As String() = line.split(","c)
        CboInvItems.Items.Add("Choose One The Following:")

        strFileName = CurDir() & "\City.txt"

        FileOpen(1, strFileName, OpenMode.Input)
        Do Until EOF(1)
            Input(1, strName)
            CboInvItems.Items.Add(strName)
        Loop
        FileClose()
    End Sub

    Private Sub CboInvItems_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CboInvItems.SelectedIndexChanged
        CboInvItems.Text = txtInventory.Text
        CboInvItems.Text = txtQty.Text
        CboInvItems.Text = txtPrice.Text
    End Sub

End Class


This post has been edited by kindie: 29 April 2010 - 03:52 PM

Was This Post Helpful? 0
  • +
  • -

Page 1 of 1