Results 1 to 5 of 5

Thread: try my code!!!

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Jan 2003
    Location
    Atlanta Ga.
    Posts
    177

    try my code!!!

    Can somone run this code for me and tell me what you think! Thanks!!




    Option Explicit
    Private Price1 As String, Price2 As String, Price3 As String
    Dim pizzaCost As Currency
    Dim TotalFrenchFryCost As Currency
    Dim TotalDrinkCost As Currency
    Dim GrandTotal As Currency


    Private Sub Quantity()


    List1.AddItem ""

    List1.AddItem "Item Quantity Price"

    List1.AddItem "pizza slices " & Val(Text1.Text) & " " & pizzaCost
    List1.AddItem "fries " & Val(Text2.Text) & " " & TotalFrenchFryCost & ".00"
    List1.AddItem "soft drinks " & Val(Text3.Text) & " " & TotalDrinkCost
    List1.AddItem " " & "--------"
    List1.AddItem "Total" & " " & "$" & GrandTotal

    End Sub

    Private Sub CostCal()
    'Find Total Cost of Items
    Price1 = 1.75
    Price2 = 1#
    Price3 = 0.75
    pizzaCost = Val(Text1.Text) * Price1
    TotalFrenchFryCost = Val(Text2.Text) * Price2
    TotalDrinkCost = Val(Text3.Text) * Price3
    GrandTotal = pizzaCost + TotalFrenchFryCost + TotalDrinkCost
    End Sub

    Private Sub cmdClick_Click()
    CostCal
    Quantity
    End Sub


    __________________

  2. #2
    PowerPoster
    Join Date
    Feb 2002
    Location
    Canada, Toronto
    Posts
    5,803
    well, first thing I think about when I look at that code, is that it needs indentation and [ vbcode ] [ /vbcode ] tags.

  3. #3
    Frenzied Member Microbasic's Avatar
    Join Date
    Mar 2001
    Posts
    1,402
    Of course,

    VB Code:
    1. Private Price1 As String, Price2 As String, Price3 As String

    Should be changed to:

    VB Code:
    1. Private Price1 As Single, Price2 As Single, Price3 As Single

    Otherwise:

    VB Code:
    1. Price1 = 1.75
    2. Price2 = 1#
    3. Price3 = 0.75

    Will not work.


    MicroBasic
    Dragon Shadow Trainer

    There is no good or evil in the world...only programmers and fools .

  4. #4
    Lively Member
    Join Date
    Nov 2002
    Location
    Perth - Australia
    Posts
    105

    Re: try my code!!!

    Originally posted by wmosley2
    List1.AddItem "Total" & " " & "$" & GrandTotal
    Maybe instead of the above line you should have:

    VB Code:
    1. List1.AddItem "Total " & Format(GrandTotal, "$0.00")
    Last edited by nightshift; Feb 4th, 2003 at 12:27 AM.

  5. #5
    PowerPoster
    Join Date
    Aug 2000
    Location
    IN SILENCE
    Posts
    6,441

    Well

    VB Code:
    1. List1.AddItem "Total " & FormatCurrency(GrandTotal, 2)
    Remaining quiet down here !!!

    BRAD HAS GIVEN ME THE ULTIMATIVE. I have chosen to stay....

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