Results 1 to 5 of 5

Thread: Re:function

  1. #1

    Thread Starter
    Member
    Join Date
    Feb 2000
    Posts
    47

    Post

    When I do I get a compile error: expected array with totPizza highlighted


    tp = FormatCurrency(totPizza(a, pizza))
    tf = FormatCurrency(totFries(b, fries))
    td = FormatCurrency(totDrink(c, sftdrks))
    totDue = FormatCurrency(totDue(totPizza, totFries, totDrink))

    MomOf3CollegeStudentTooMuchToDoNeverEnoughTime

    Using VB6 Working Model Edition

  2. #2
    Fanatic Member r0ach's Avatar
    Join Date
    Dec 1999
    Location
    South Africa
    Posts
    722

    Post Re: Re:function

    Here's your fixed program:
    Code:
    Option Explicit
    
    Private Sub cmdCompute_Click()
    'request order and calculate bill
    Dim pizza As Single, fries As Single, sftdrks As Single, _
    fmt As String, totPizza As Single, totFries As Single, _
    totDrink As Single, totDue As Single, tp As Single, tf As Single, _
    td As Single, a As Single, b As Single, c As Single
    
        Call InputOrder(pizza, fries, sftdrks)
        Call DisplayBill(fmt, totPizza, totFries, totDrink, totDue, pizza, fries, sftdrks, tp, tf, td, a, b, c)
    End Sub
    
    Private Sub InputOrder(pizza As Single, fries As Single, _
    sftdrks As Single)
    'get the order
        pizza = Val(txtPizza.Text)
        fries = Val(txtFries.Text)
        sftdrks = Val(txtDrink.Text)
    End Sub
    
    Private Sub DisplayBill(fmt As String, totPizza As Single, _
    totFries As Single, totDrink As Single, totDue As Single, _
    pizza As Single, fries As Single, sftdrks As Single, tp As Single, _
    tf As Single, td As Single, a As Single, b As Single, c As Single)
    'display order and amt due
        picOutput.Cls
        picOutput.FontBold = True
        picOutput.Font = "Courier"
        fmt = "$ ###,##0.00"
        tp = ftotPizza(a, pizza)
        tf = ftotFries(b, fries)
        td = ftotDrink(c, sftdrks)
        totDue = ftotDue(tp, tf, td)
        picOutput.Print "Item"; Tab(14); "Quantity"; Tab(39); "Price"
        picOutput.Print
        picOutput.FontBold = False
        picOutput.Print "pizza slices"; Tab(17); pizza; Tab(40);
        picOutput.Print Format(tp, fmt)
        picOutput.Print "fries"; Tab(17); fries; Tab(40); Format(tf, fmt)
        picOutput.Print "soft drinks"; Tab(12); sftdrks; Tab(40);
        picOutput.Print Format(td, fmt)
        picOutput.Print
        picOutput.FontBold = True
        picOutput.Print "Total"; Tab(35); Format(totDue, fmt)
    End Sub
    
    Private Function ftotPizza(a As Single, pizza As Single) As Single
        a = 1.25
        ftotPizza = a * pizza
    End Function
    
    Private Function ftotFries(b As Single, fries As Single) As Single
        b = 1
        ftotFries = b * fries
    End Function
    
    Private Function ftotDrink(c As Single, sftdrks As Single) As Single
        c = 0.75
        ftotDrink = c * sftdrks
    End Function
    
    Private Function ftotDue(totPizza As Single, totFries As Single, _
    totDrink As Single) As Single
        ftotDue = totPizza + totFries + totDrink
    End Function
    
    Private Sub cmdExit_Click()
        End
    End Sub
    Compare the code carefully to see your mistakes.

    r0ach™
    Don't forget to rate the post

  3. #3

    Thread Starter
    Member
    Join Date
    Feb 2000
    Posts
    47

    Post Re: Re:function

    Thanks, I'll try it and let you know. I do have to format my numbers to right justify - does (below) do this?

    fmt = "$ ###,##0.00"

  4. #4
    Fanatic Member r0ach's Avatar
    Join Date
    Dec 1999
    Location
    South Africa
    Posts
    722

    Post

    I believe so. I'm not 100% sure

    r0ach™
    Don't forget to rate the post

  5. #5
    Frenzied Member
    Join Date
    Jan 2000
    Location
    Bellevue, WA, USA
    Posts
    1,357

    Post

    Try this:

    Format(VariableName, "currency")

    ~seaweed

    P.S. See my reply to your last post...I already solved this for you!

    http://www.vb-world.net/forums/showthread.php?threadid=9985


    Edited by seaweed on 02-23-2000 at 03:37 PM

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