• Named Arguments (Microsoft VB 6.3)

    Author
    Topic
    #409891

    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?

    Viewing 1 reply thread
    Author
    Replies
    • #876935

      >”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”.

      • #876991

        Two questions:

        1) What is intellisense?

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

        • #877008

          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”.

        • #877009

          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”.

        • #877157

          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

        • #877158

          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

        • #877279

          (Edited by jscher2000 on 14-Sep-04 17:53. Little IntelliSense picture added.)

          When I open Word, create a blank document, display the VBE, display the immediate window and run this:

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

          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:

          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
          

          Your code almost certainly will be more intelligent. smile

        • #877280

          (Edited by jscher2000 on 14-Sep-04 17:53. Little IntelliSense picture added.)

          When I open Word, create a blank document, display the VBE, display the immediate window and run this:

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

          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:

          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
          

          Your code almost certainly will be more intelligent. smile

        • #877309

          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

        • #877310

          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

      • #876992

        Two questions:

        1) What is intellisense?

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

    • #876936

      >”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”.

    Viewing 1 reply thread
    Reply To: Named Arguments (Microsoft VB 6.3)

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information: