Results 1 to 2 of 2

Thread: beginner needs help

  1. #1

    Thread Starter
    New Member
    Join Date
    Apr 2011
    Posts
    1

    beginner needs help

    I am a begginer to programing and a student. I need alot of help with the program I'm trying to write. I need my program to output and input a customer ID and sales amount multiple times. I need it to display both outputs, customer ID and sales amount, on mulltiple lines. It also will need to accumulate the sales amount and then display the total sales. it should look something like that.

    ab2 751.60
    bn4 395.60
    cr7 203.53

    Total Sales: $1,350.85


    I think that I was supposed to use a messagebox but wrote the program a different way. the form.vb was already locked, but I added two text boxs. Not sure if I did this right because I need to enter multiple sales for one customer ID.

    Here is what I have wrote so far and any help or pointer could be great help. Like I said I'm a biginner and so I may way off on what I want to do.

    Private Sub btnDisplay_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnDisplay.Click
    'Calculates and displays ID, sales, and total sales

    Dim numCounter As Decimal


    txtTotalSales.Text = String.Empty

    numCounter = 1

    'calculation
    Do Until numCounter > 10
    For sales As Decimal = 1 To 1
    txtTotalSales.Text = txtIdEntered.Text & " " & txtSalesEnterd.Text & ControlChars.NewLine
    For idEntered As Decimal = 1 To 1
    txtTotalSales.Text = txtIdEntered.Text & " " & txtSalesEnterd.Text & ControlChars.NewLine
    Next idEntered
    txtTotalSales.Text = txtTotalSales.Text & ControlChars.NewLine
    Next sales
    numCounter = numCounter + 1
    Loop

    End Sub
    End Class

  2. #2
    PowerPoster kaliman79912's Avatar
    Join Date
    Jan 2009
    Location
    Ciudad Juarez, Chihuahua. Mexico
    Posts
    2,593

    Re: beginner needs help

    OK, the best way to learn is to do it. but you have a lot of areas where your code can be better. I will give you a few pointers without doing your homework for you

    1) If you want to do a loop that repeats 10 times do not use a Do Until loop, use a For ... Next loop:

    For i=1 to 10
    ...
    Next i

    2) Inside your code you have two loops (For sales As Decimal = 1 To 1) these loops are useless since they "loop" only once. Meaning they do not repeat at all.

    3) It appears as if you are using txtSalesEntered as your input textbox, but I think you are trying to loop 10 times to get information out of it and if you were to succeed the way you are going, you would get the same text 10 times. You either need 10 textboxes or an inputBox (which is discontinued for newer versions of VB).

    4) Your program does not try to do anything at the end when it "adds" all data. It should then try to display the totals.

    Hope this helps
    More important than the will to succeed, is the will to prepare for success.

    Please rate the posts, your comments are the fuel to keep helping people

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