Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Please help Newbie

VyadVyad Member Posts: 3
Hi, I'm new to the forums :)

I'm at a loss on a programming challenge I have. The application prompts a user to enter sales for 5 stores, then display the result in a list box.

The problem I'm having is that the challenge requires the results to be displayed in the list box as a row of asterisks with each asterisk representing $100 of that stores sales.

So, if store 1 sold $500 worth of product, the list box should look like:

Store 1: *****

Here is my code. I'm absolutely stuck here. I'm not looking for the solution, only help in getting that solution ;)
_________________________________________________


Dim intSales1 As Integer 'Day 1 Sales
Dim intSales2 As Integer 'Day 2 Sales
Dim intSales3 As Integer 'Day 3 Sales
Dim intSales4 As Integer 'Day 4 Sales
Dim intSales5 As Integer 'Day 5 Sales
Dim ast As String = "*"
Dim count As Integer

intSales1 = InputBox("Enter the sales for store one", "Enter Sales")
intSales2 = InputBox("Enter the sales for store two", "Enter Sales")
intSales3 = InputBox("Enter the sales for store three", "Enter Sales")
intSales4 = InputBox("Enter the sales for store four", "Enter Sales")
intSales5 = InputBox("Enter the sales for store five", "Enter Sales")

If Not IsNumeric(intSales1) Then
MessageBox.Show("Please enter a number.")
ElseIf intSales1 < 0 Then
MessageBox.Show("Negative numbers are not acceptable. That manager is FIRED!")
Else
lstSales.Items.Add("Store 1: " & ast)
End If

_________________________________________________________

I know the code is incomplete, I just need to make store 1 sales output properly, then I can copy the code for the rest of the days.

Comments

  • HackmanCHackmanC Member Posts: 441
    You can make a loop and add a star for each $100
    I'll write pseudo-code...

    Integer Sold = 500
    While (Sold > 0) [color=Green]' 501 = ** ** ** = 6 stars[/color]
    Sold = Sold - 100
    Stars = Stars + "*"
    Wend

    That was without using libraries.
    And using VB libraries with pseudo-code...

    Stars = Strings.Repeat("*", Stars / 100) [color=Green]' 501 = (501 / 100) = 5.01 = *****[/color]

    http://www.dreamincode.net/forums/showtopic13107.htm

    [red]Good luck![/red]
    [blue]Hackman[/blue]
  • VyadVyad Member Posts: 3
    Thanks for the advice so far :). I still dont get it though. I'm trying the loop method but I still cannot get it to work. I've altered the code but the stars are showing up in different rows instead of the same. Everything I try to do to multiply the number of stars by the daily sales / 100 gives me an error. This is what I have right now. i know this should be simple, so I must be missing something simple ;(

    ________________________________________

    Dim intSales1 As Integer 'Day 1 Sales

    Dim star As String = "*"
    Dim count As Integer = 0

    intSales1 = InputBox("Enter the sales for store one", "Enter Sales")


    If Not IsNumeric(intSales1) Then
    MessageBox.Show("Please enter a number.")
    ElseIf intSales1 < 0 Then
    MessageBox.Show("Negative numbers are not acceptable. That manager is FIRED!")
    Else
    Do Until count = intSales1 / 100
    count += 1
    lstSales.Items.Add(star)
    Loop

    End If
  • VyadVyad Member Posts: 3
    Ok, got 'er workin. Thanks for the help!
Sign In or Register to comment.