如何记录库存值等

时间:2015-10-26 16:11:35

标签: vb.net

我会在我上学的文件下面发帖。基本上我有库存量和销售价格。我必须弄清楚如何显示每个的价值 项目。我唯一知道如何做到这一点就是一次做一个。

股票#,Descrip,促销价,Iventory

ET001,1抽屉结束表,169.99,10

ET002,2抽屉结束表,289.95,05

ET003,6抽屉结束表,129.99,02

ST001,Stacking Table,320.75,20

1 个答案:

答案 0 :(得分:0)

您仍然需要读入文件并解析内容。我建议在StreamReader块中使用Using来读取每行文本,然后使用.Split(",")行数据来获取值。一旦解析了这些值,就应该以这个简单的控制台应用程序作为起点,直截了当地进行。

Option Strict On
Option Explicit On

Module Module1
    Sub Main()
        ' Create a list to hold the items
        Dim slist As New List(Of StockItem)

        ' Get your file contents and parse out the data then add it to the list. Done manually below
        slist.Add(New StockItem With {.StockCode = "ET001", .Description = "1 Drawer End table", .SalePrice = 169.99D, .Inventory = 10I})
        slist.Add(New StockItem With {.StockCode = "ET002", .Description = "2 Drawer End table", .SalePrice = 289.99D, .Inventory = 5I})

        'Loop Through all Items and get the values. 
        For Each item As StockItem In slist
            'Write it out to the Debug
            Debug.WriteLine(item.GetValue())
        Next
    End Sub
End Module

Public Structure StockItem
    Public Property StockCode As String
    Public Property Description As String
    Public Property SalePrice As Decimal
    Public Property Inventory As Integer

    Public Function GetValue() As Decimal
        Return CDec(Me.SalePrice * Me.Inventory)
    End Function
End Structure