Results 1 to 8 of 8
  1. #1
    Gold Lounger
    Join Date
    Dec 2000
    Location
    Hollywood (sorta), California, USA
    Posts
    2,759
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Dumb Question? (Word 97SR2)

    Can I create a function which, when I type the argument value, prompts me (intellisense) with the available values -- the way any boolean argument does.

    For exampe, if I call my function like this:

    If EatThisWay(Vegetable,True) then
    'do this
    endif

    and the function is defined like this:

    Function EatThisWay(sKind as SomeTypeofFood, Raw as Boolean)
    ' code
    end Function

    ...when I type the ( intellisense prompts me with SomeTypeOfFoodVar. When I type the comma, intellisense prompts me with TRUE and FALSE in a dropdown.

    If I define SomeTypeOfFood as having only 5 values: meat, vegetable, dairy, fish and grain, can VBA prompt me with a dropdown of just those values just like it does for boolean values?

    Am I making any sense here? How do I define SomeTypeOfFood to have only 5 values anyway?
    Kevin <IMG SRC=http://www.wopr.com/w3tuserpics/Kevin_sig.gif alt="Keep the change, ya filthy animal...">
    <img src=/w3timages/blackline.gif width=33% height=2><img src=/w3timages/redline.gif width=33% height=2><img src=/w3timages/blackline.gif width=33% height=2>

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

    Re: Dumb Question? (Word 97SR2)

    Kevin,

    Not exactly what you asked for, but you can get pretty close with an Enum variable...

    <pre>Public Enum fdFoodType
    fdMeat = 1
    fdDairy = 2
    fdFish = 3
    fdVegetable = 4
    fdGrain = 5
    End Enum

    Function EatThisWay(sKind As fdFoodType, Raw As Boolean) As Integer
    EatThisWay = sKind
    End Function


    Sub FoodTest()
    Dim x As Integer
    x = EatThisWay(fdMeat, True)
    End Sub
    </pre>

    When you enter the line x=EatThisWay( you get a reasonable prompt.

    StuartR

  3. #3
    Silver Lounger
    Join Date
    Mar 2001
    Location
    Springfield, Ohio, USA
    Posts
    2,136
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Dumb Question? (Word 97SR2)

    Good news, bad news. Good: That's what Enum's are for. Bad: Not in 97, Bill needs more money! When are you and I going to upgrade? Have XP at home, but when I bring it to work, 97 <img src=/S/barf.gif border=0 alt=barf width=64 height=23>
    <font face="Comic Sans MS">Sam Barrett, CACI </font face=comic>
    <small>And the things that you have heard... commit these to faithful men who will be able to teach others also. 2 Timothy 2:2</small>

  4. #4
    Gold Lounger
    Join Date
    Dec 2000
    Location
    Hollywood (sorta), California, USA
    Posts
    2,759
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Dumb Question? (Word 97SR2)

    Stuart,

    Here's as far as I can get with enumerated values in VBA5:

    "It is good programming practice to define constants using the Const statement for each enumerated value." - the Help

    But thanks for pointing me in the right direction. In about 2 months, I'll be developing exclusively in Office Xp. Goodbye 97.
    Kevin <IMG SRC=http://www.wopr.com/w3tuserpics/Kevin_sig.gif alt="Keep the change, ya filthy animal...">
    <img src=/w3timages/blackline.gif width=33% height=2><img src=/w3timages/redline.gif width=33% height=2><img src=/w3timages/blackline.gif width=33% height=2>

  5. #5
    Silver Lounger
    Join Date
    Mar 2001
    Location
    Springfield, Ohio, USA
    Posts
    2,136
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Dumb Question? (Word 97SR2)

    <img src=/S/yep.gif border=0 alt=yep width=15 height=15>, but not in 97:
    Attached Images Attached Images
    <font face="Comic Sans MS">Sam Barrett, CACI </font face=comic>
    <small>And the things that you have heard... commit these to faithful men who will be able to teach others also. 2 Timothy 2:2</small>

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

    Re: Dumb Question? (Word 97SR2)

    Woops <img src=/S/blush.gif border=0 alt=blush width=15 height=15>

    It really isn't my day for giving correct answers in the lounge, methings it must be approaching time for bed <img src=/S/yawn.gif border=0 alt=yawn width=15 height=15>

    StuartR

  7. #7
    Gold Lounger
    Join Date
    Dec 2000
    Location
    Hollywood (sorta), California, USA
    Posts
    2,759
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Dumb Question? (Word 97SR2)

    Sammy,
    The good news for me is we're heading to Office Xp in several months.

    Have you seen the .Net IDE? It's a thing of beauty. I wonder if you can develop Office VBA apps in .Net.
    Probably not. That's what Office .Net (or whatever it'll be called) is for?

    You can install XP and 97 on the same machine, you know. I'm doing on a box here.
    Kevin <IMG SRC=http://www.wopr.com/w3tuserpics/Kevin_sig.gif alt="Keep the change, ya filthy animal...">
    <img src=/w3timages/blackline.gif width=33% height=2><img src=/w3timages/redline.gif width=33% height=2><img src=/w3timages/blackline.gif width=33% height=2>

  8. #8
    Plutonium Lounger
    Join Date
    Dec 2000
    Location
    Sacramento, California, USA
    Posts
    16,775
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Dumb Question? (Word 97SR2)

    You'll like enums in VBA in 200x. I hate not having them when I have to work in 97 ... along with several other neat features like Split() and Join()! <img src=/S/grin.gif border=0 alt=grin width=15 height=15>
    Charlotte

Posting Permissions

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