Results 1 to 5 of 5

Thread: Problem with my function

  1. #1

    Thread Starter
    New Member
    Join Date
    Jun 2008
    Posts
    2

    Problem with my function

    Sorry if this is the wrong spot for this, but i'm currently writing code in Microsoft Visual Basic in excel 2000.

    here is the beginning of a function

    Function ErlBLines(blockingProbablity as Double, traffic as Double) as Double
    ...
    ...
    End Function


    One thing i could do with Python is give a variable a value that was optional. Basically it would remain the same value unless the user changed it.


    so in python what i wan to do would look like this


    def ErlBLines(blockingProbability, traffic, error=0):
    ...
    ...
    return ...

    Is there a way i can do this in VB?

    Basically i want ether of these to be acceptable inputs in excel.

    =ErlBLines(.02,10)

    And

    =ErlBLines(.02,10,.1)


    Thanks for your help in advance

  2. #2
    Addicted Member Veritas2.0's Avatar
    Join Date
    May 2008
    Posts
    181

    Re: Problem with my function

    I'm pretty sure that's actually VBA that you are working with but this work.

    VB Code:
    1. Function ErlBLines(blockingProbablity as Double, traffic as Double,Optional otherVariable As Something = 0) as Double
    2. ...
    3. ...
    4. End Function
    Simple little bugs 13 : Me 1

    Law of Bugs - That one bug you missed will be found almost immediately, by your customer.

    I wonder if anyone has ever asked for a User Surly interface?

  3. #3
    New Member
    Join Date
    Aug 2005
    Posts
    15

    Re: Problem with my function

    I thought I could help....I opened Excel, I wrote basically the same as what was posted above, I rejoiced in my success, I came back to the webpage, and it had already been answered

    Nice work Veritas

  4. #4

    Thread Starter
    New Member
    Join Date
    Jun 2008
    Posts
    2

    Re: Problem with my function

    Thanks alot, that does the trick. I did a little bit of programming in vb like 5 years ago for HS, but i've forgotten it all so now i'm teaching myself it on the job. Got to love google and the forums 2.

    Yea VBA sounds right, but i don't know what the difference is.

  5. #5
    Super Moderator si_the_geek's Avatar
    Join Date
    Jul 2002
    Location
    Bristol, UK
    Posts
    41,974

    Re: Problem with my function

    It is actually VBA, but unfortunately that isn't made particularly obvious (even the About screen gives the impression it is VB). There are lots of similarities, but there are also some differences (particularly when it comes to controls) which can easily cause confusion.

    As such, this thread belongs in our Office Development/VBA forum, and I have moved it there.


    As you now have this question sorted out, could you please do us a little favour, and mark the thread as Resolved?
    (this saves time reading for those of us who like to answer questions, and also helps those who search to find answers)

    You can do this by clicking on "Thread tools" just above the first post in this thread, then "Mark thread resolved".

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