(Solved) – Using Generics in Visual Basic How do i read in orders from a line in a text file and save using space as the delimeter

  • by

‘Each line in the file consists of an employee’s first name, last name, sales order ID number, employee ‘ID number, games sales amount, games sales quantity (number of customers who bought games on this ‘particular order), dolls sales amount, dolls quantity, building sets sales amount, building set ‘quantity, models sales amount and model quantity. I need to build a class (it doesn’t have to be a ‘properly designed class, e.g. don’t worry about using getters/setters, just do what was shown in the ‘latest chapter) which will store the following information on an employee:

     strFirstName As String
     strLastName As String
     intOrderID As Integer
     intID As Integer
     sngGamesSales As Single
     intGamesQuantity As Integer
     sngDollsSales As Single
     intDollsQuantity As Integer
     sngBuildingSales As Single
     intBuildingQuantity As Integer
     sngModelSales As Single
     intModelQuantity As Single
     sngTotalSales As Single

‘I then need to produce a report that is formatted where they are sorted based on order number

‘ My code so far looks like this

Public Class frmToyOrder

Public Property strFirstName As String
Public Property strLastName As String
Public Property intOrderID As Integer
Public Property intID As Integer
Public Property sngGamesSales As Single
Public Property intGamesQuantity As Integer
Public Property sngDollsSales As Single
Public Property intDollsQuantity As Integer
Public Property sngBuildingSales As Single
Public Property intBuildingQuantity As Integer
Public Property sngModelSales As Single
Public Property intModelQuantity As Single
Public Property sngTotalSales As Single

Sub Main()
    Dim myOrders As New ArrayListOfToyOrders

End Sub

Public Sub New(ByVal firstName As String, ByVal lastName As String, ByVal orderID As Integer, ByVal ID As Integer, ByVal games As Single, ByVal gamesQuantity As Integer, ByVal dollSales As Integer, ByVal dollsQuantity As Integer, ByVal buildingSales As Single, ByVal buildingQuantity As Integer, ByVal modelSales As Single, ByVal modelQuantity As Single, ByVal totalSales As Single)

    Me.strFirstName = firstName
    Me.strLastName = lastName
    Me.intOrderID = orderID
    Me.intID = ID
    Me.sngGamesSales = games
    Me.intGamesQuantity = gamesQuantity
    Me.sngDollsSales = dollSales
    Me.intDollsQuantity = dollsQuantity
    Me.sngBuildingSales = buildingSales
    Me.intBuildingQuantity = buildingQuantity
    Me.sngModelSales = modelSales
    Me.intModelQuantity = modelQuantity
    Me.sngTotalSales = totalSales

End Sub

'Split the lines of the text file to an array 
Dim arr() As String

Public Overrides Function ToString() As String
    Return String.Format("First Name: {0}, Last Name: {1}, Order ID: {2}, Int ID: {3}, Games Sales: {4}, Games Quantity: {5}, Dolls Sales: {6}, Dolls Quantity: {7}, Building Sales: {8}, Building Quantity: {9}, Model Sales: {10}, Model Quantity: {11}, Total Sales: {12}", strFirstName, strLastName, intOrderID, intID, sngGamesSales, intGamesQuantity, sngDollsSales, intDollsQuantity, sngBuildingSales, intBuildingQuantity, sngModelSales, intModelQuantity, sngTotalSales)
End Function

End Class

Leave a Reply

Your email address will not be published. Required fields are marked *