CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 8 of 8
  1. #1
    Join Date
    Jul 2013
    Posts
    5

    Exclamation VB 2010 Assignment

    Ive gotten the file to come up in the list box but thats about it


    Task
    1) A Comma Separated file contains an unknown number of entries. Each entry (record) contains a sales record. The sales record has the following information
    SalesClerkID example 12345
    Date of Sale 01/01/01
    Amount of Sale $125.83
    SaleItemSKU 837593

    Each field is seprated by commas in this text file. the text file can be assumed to have records already sorted in the order of SalesClerkID

    Your task
    Record each record
    Display on the screen the clerk's ID # and the amount of the sale
    At the end of the clerk's sale(befored printing the next clerk's sales) display "Total:xxxxx Count:xxxxx Average:xxxxx" total sales amount, number of sales and the average sale for that clerk
    skip one line between clerks
    at the very end, print the grand total for all clerks and the average sale amount for all clerks
    while you are told the records are alredy in sales clerk order, you dont know how many records or how many clerks, etc

    GUI has a button and a listbox for output


    txt file
    12340,01/01/01,4123.13,876543
    12341,01/01/01,123.33,765432
    12342,01/01/01,4123.94,654321
    12343,01/01/01,41.85,987650
    12344,01/01/01,43.83,976541
    12345,01/01/01,423.86,976542
    12346,01/01/01,412.73,976543
    12347,01/01/01,123.68,976544
    12348,01/01/01,12.53,976545
    12349,01/01/01,23.40,976546




    this is what i have
    Code:
    Public Class Form1
    Structure Clerk
    Dim ClerkID As String
    Dim DOS As String
    Dim Amount As Double
    Dim SKU As String
    
    End Structure
    
    
    Private Sub LstClerks_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles LstClerks.SelectedIndexChanged
    
    
    
    
    
    End Sub
    
    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    Dim Clerks() As String = IO.File.ReadAllLines("E:/Question4.txt")
    Dim query = From line In Clerks
    Let data = line.Split(","c)
    Let ClerkID = data(0)
    Let DOS = data(1)
    Let Amount = data(2)
    Let SKU = data(3)
    Select ClerkID, DOS, Amount, SKU
    For Each Clerk In query
    LstClerks.Items.Add("ID" & Clerk.ClerkID & " " & "Amount of Sale" & Clerk.Amount)
    
    Next
    
    
    End Sub
    
    
    
    
    End Class

  2. #2
    Join Date
    Jul 2008
    Location
    WV
    Posts
    5,362

    Re: VB 2010 Assignment

    First of all do not start more than one thread for the same question.
    Secondly use code tags when posting code.

    I think this is the first time I have saw the Let keyword used in almost 20 years You do know that is not needed and hasn't been needed for a very very long time. Last I remember using it was in the 80s.

    Surely this line is causing a build error
    Dim query = From line In Clerks

    Aside from that you did not really ask a question so I don;t know what to say other than we do not do homework for you, If you have a question ask away and someone may answer.
    Always use [code][/code] tags when posting code.

  3. #3
    Join Date
    Jul 2013
    Posts
    5

    Re: VB 2010 Assignment

    the Dim Query = From Line in Clerks isnt causing a build error.

    I need help writing a code to read my info into an array, and then s loop through the array to create an average

  4. #4
    Join Date
    Jul 2013
    Posts
    5

    Re: VB 2010 Assignment

    and sorry about all the noob posting mistakes

  5. #5
    Join Date
    Jul 2013
    Posts
    5

    Post Function/ Case Help

    Can anyone help me out

    Read a text file containing a single student's grades. Each line simply contains a letter grade. You can assume that each course is 3 credits
    Task: Compute the student's GPA
    Grade table is as follows
    A 4.0
    A- 3.67
    B+ 3.33
    B 3.0
    B- 2.67
    C+ 2.33
    C 2.0
    C- 1.67
    D 1.0
    F 0

    GPA is computed by obtaining the total quality points and dividing by total credits
    Quality Points are calculated by multiplying the points for the grade by the number of credits

    the output should read "student's GPa is xx.xx" usising two decimal places
    The GUI is a Button and an output label

    txtfile

    A

    A-

    C

    D

    C-

    B

    Code:
    Public Class Form1
        Dim tempGradeArray() As String
        Dim letterArray(1) As String
        Dim scoreArray(1) As Double
        Dim i As Integer = 0
    
     
    
    
        Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
            Dim gradeReader As New System.IO.StreamReader("Grades.txt")
            Do Until gradeReader.EndOfStream()
                tempGradeArray = Split(gradeReader.ReadLine(), " ", 2)
                letterArray(i) = tempGradeArray(0)
                scoreArray(i) = CDbl(tempGradeArray(0))
                ReDim Preserve letterArray(i + 1) ' redim allows you to make an array bigger or smaller
                ReDim Preserve scoreArray(i + 1) ' preserve saves the data in the array, if you don't do this, then you loose the array info
                i += 1
            Loop
       
    
        End Sub
    
        Private Sub TextBox1_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox1.TextChanged
           
        End Sub
        Private Function GetQualityPoints()
            Select Case Grade
    
    
    
    
    
    
    
    
    
    
            End Select
    
        End Function
    
    End Class
    I need help coming up with a function to calculate the values of the text file and make a case for each

  6. #6
    Join Date
    Jan 2006
    Location
    Fox Lake, IL
    Posts
    15,007

    Re: Function/ Case Help

    We don't do homework for people, sorry. Think about it for a minute, and look up SELECT CASE to see how to use it!
    David

    CodeGuru Article: Bound Controls are Evil-VB6
    2013 Samples: MS CODE Samples

    CodeGuru Reviewer
    2006 Dell CSP
    2006, 2007 & 2008 MVP Visual Basic
    If your question has been answered satisfactorily, and it has been helpful, then, please, Rate this Post!

  7. #7
    Join Date
    Jul 2001
    Location
    Sunny South Africa
    Posts
    11,283

    Re: VB 2010 Assignment

    Let? Wow! OK, a teacher teaches you that?

    Anyways, you need to brush up on your string manipulation skills.

    You could look into :

    Substring
    IndexOf
    Split

  8. #8
    Join Date
    Jul 2001
    Location
    Sunny South Africa
    Posts
    11,283

    Re: VB 2010 Assignment

    [Merged Thread]

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured