Results 1 to 7 of 7
  1. #1
    3 Star Lounger
    Join Date
    Sep 2004
    Location
    Portsmouth, Hampshire, England
    Posts
    200
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Named Arguments (Microsoft VB 6.3)

    The help for IIF (which I have wanted for ages but have only just discovered from a post in the WOPR Excel forum) says:
    Syntax

    IIf(expr, truepart, falsepart)

    The IIf function syntax has these named arguments:

    Part Description
    expr Required. Expression you want to evaluate.
    truepart Required. Value or expression returned if expr is True.
    falsepart Required. Value or expression returned if expr is False.

    But these appear to be position arguments rather than named arguments. Am I crazy or is it the help?

    Or, can they be used as either named or positional arguments?

  2. #2
    Gold Lounger
    Join Date
    Dec 2000
    Location
    New Hampshire, USA
    Posts
    3,386
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Named Arguments (Microsoft VB 6.3)

    >"Am I crazy or is it the help?"

    Well, I don't know you, so I cannot tell whether you are crazy, but the "help" is wrong.

    If you use intellisense, you will see the correct arg is "Expression", not "expr".

  3. #3
    3 Star Lounger
    Join Date
    Sep 2004
    Location
    Portsmouth, Hampshire, England
    Posts
    200
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Named Arguments (Microsoft VB 6.3)

    Two questions:

    1) What is intellisense?

    2) Is it possible to define named arguments for a UDF?

  4. #4
    Gold Lounger
    Join Date
    Dec 2000
    Location
    New Hampshire, USA
    Posts
    3,386
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Named Arguments (Microsoft VB 6.3)

    You should have intellisense automatically, unless you unchecked the options in Tool | Options | editor in the VBIDE.

    The names of the args in each function/sub are the "named arguments".

  5. #5
    Plutonium Lounger
    Join Date
    Nov 2001
    Posts
    10,550
    Thanks
    0
    Thanked 7 Times in 7 Posts

    Re: Named Arguments (Microsoft VB 6.3)

    Intellisense is the feature of the VB editor that causes it to suggest properties, methods and other valid things as you start to type.

    StuartR

  6. #6
    Super Moderator jscher2000's Avatar
    Join Date
    Feb 2001
    Location
    Silicon Valley, USA
    Posts
    23,112
    Thanks
    5
    Thanked 93 Times in 89 Posts

    Re: Named Arguments (Microsoft VB 6.3)

    <P ID="edit" class=small>(Edited by jscher2000 on 14-Sep-04 17:53. Little IntelliSense picture added.)</P>When I open Word, create a blank document, display the VBE, display the immediate window and run this:

    <code>Selection.TypeText IIf(Expression:=1 = 1, FalsePart:="It's a lie", TruePart:="It's true!")</code>


    It works.

    By UDF you mean "user defined function"? Is this an Excel thing or a VB thing? If you mean a VB function, this lame example works in VBA:
    <pre>Sub ShoutItOut()
    BoxItUp TheCaption:="You're Invited", TheWord:="Dinner at 8", HighStress:=False
    BoxItUp HighStress:=True, TheWord:="You're late!!"
    End Sub

    Function BoxItUp(TheWord As String, Optional TheCaption As String = "Yo!", _
    Optional HighStress As Boolean = False)
    MsgBox Prompt:=TheWord, _
    Buttons:=IIf(HighStress, vbExclamation, vbInformation), _
    Title:=TheCaption
    End Function
    </pre>

    Your code almost certainly will be more intelligent. <img src=/S/smile.gif border=0 alt=smile width=15 height=15>

  7. #7
    Bronze Lounger
    Join Date
    Nov 2001
    Location
    Arlington, Virginia, USA
    Posts
    1,394
    Thanks
    0
    Thanked 3 Times in 3 Posts

    Re: Named Arguments (Microsoft VB 6.3)

    In reference to "What is 'Intellisense'", for a brief description see MSDN Library:

    MSDN - VB Documentation - Using the Code Editor

    See section titled "Automatic Code Completion." The features commonly referred to as "Intellisense" (or "Statement Completion") include Auto List Members, Auto Quick Info, Auto Data Tips. The Visual Basic IDE did not always provide Intellisense; it was introduced with VB version 5.0. One of the main individuals responsible for the implementation of Intellisense in the VB IDE was a very smart guy named Matt Curland, a member of the Microsoft Visual Studio development team and author of "Advanced Visual Basic 6" (Addison-Wesley, 2000). He contributed an essay for The Apress VB@10 Call for Essays on the occasion of Visual Basic's 10th anniversary, that discusses his work on Intellisense, among other things. Link to article:

    VB @ 10 Years - Matthew Curland: "VB lets me focus on my Program, not my Code"

    The other essays on the Apress VB @ 10 Years page are also worth a look for those interested in the evolution of VB from its primitive BASIC origins to its current incarnation as VB.NET.

    PS: As for IIF function, in this case the "Intellisense" is more intelligent than "Help", since it gets its info from the type library . Where "Help" got its bogus info from, who knows.

    HTH

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •