Page 1 of 2 12 LastLast
Results 1 to 15 of 24
  1. #1
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: vbYesNoAll (all)

    I would make the arguments of MsgBoxYesNoAll optional, and unload the userform (in the code as written by you, it is only hidden, but stays in memory).

    Public Function MsgBoxYesNoAll( _
    Optional strPrompt As String, _
    Optional strTitle As String) As Long
    Load frmYesnoAll
    If Trim(strTitle) <> "" Then
    frmYesNoAll.Caption = strTitle
    End If
    If Trim(strPrompt) <> "" Then
    frmYesNoAll.lblPrompt.Caption = strPrompt
    End If
    frmYesNoAll.Show
    MsgBoxYesNoAll = frmYesNoAll.lblPrompt.Tag
    Unload frmYesNoAll
    End Function

    I would also define a public constant vbAll

    Public Const vbAll = 8

    This is consistent with vbYes and vbNo, and makes the code more readable:

    Select Case MsgBoxYesNoAll("Click the button of your choice.")
    Case vbYes
    ...
    Case vbNo
    ...
    Case vbAll
    ...
    End Select

  2. #2
    Platinum Lounger
    Join Date
    Feb 2001
    Location
    Yilgarn region of Toronto, Ontario
    Posts
    5,453
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: vbYesNoAll (all)

    Hans, thanks for the fast feedback (as disticnt from feeding my fastback ...)

    I take it from your efforts that there is no supplied YesNoAll facility in the realm of MsgBox/InputBox?


    >make the arguments of MsgBoxYesNoAll optional
    I considered this, but decided against it on the grounds that
    (a) it might blur the issue (that I can see no Yes/No/All option and
    ([img]/forums/images/smilies/cool.gif[/img] I had a fling with "Optional" a year or two ago, and became unravelled when i was losing my type-checking. I think it was "Optional" with a "Type" that caused me to receive a value (e.g. "" for an optional of type String). With "Type" in place, a missing optional string became "", and no longer missing.


    > unload the userform
    I still have doubts about this. How much memory does it take, and given that it may be used again, why go to the trouble of unloading it? How is WinXP's memory-swapping doing nowadays?
    "Hidden" has the advantage that I can still see the variables.

    In general, I've avoided Unloading forms, unless, for some reason, I've wanted to be sure to re-run the .Initialize routine next time I use the form. This does have relevance to me, because I populate various user text/check boxes from INI files.

  3. #3
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: vbYesNoAll (all)

    1. The six built-in message box button combinations can be found in the VBA help:
    vbOKOnly (default)
    vbOKCancel
    vbYesNo
    vbYesNoCancel
    vbRetryCancel
    vbAbortRetryIgnore

    2. If you have an optional typed argument, it will never be missing - if the user doesn't supply it, it will be the default value for that type ("", 0, False). In your function, I don't see a problem with that. Calling MsgBoxYesNoAll("Click the button of your choice") seems more user-friendly to me than MsgBoxYesNoAll("Click the button of your choice", ""), but the effect will be the same. If you would like to use the IsMissing function, leave the argument untyped - variants can be missing.

    3. I don't think the overhead of not unloading a form is very great. I was concerned about the UserForm_Initialize routine not being run again, and controls and variables not being cleared. If you're not aware of that, it could lead to unexpected results.

  4. #4
    Platinum Lounger
    Join Date
    Feb 2001
    Location
    Yilgarn region of Toronto, Ontario
    Posts
    5,453
    Thanks
    0
    Thanked 0 Times in 0 Posts

    vbYesNoAll (all)

    I couldn't find a MsgBox with a button set "Yes, No, All", so I wrote a crude facsimile (attached).

    If I missed something in the WordXP help files, I'd appreciate hearing about it.

    Further: I recall, about six months ago, reading a message on standard command button sizes, but I can't find it here (searching for "command standard size" and 'command standard height width"), so if anyone recalls it, I'll clean up my attachment and re-post. Thanks.

    (2005/01/24 Modified in the light of HANS'S COMMENTS)

  5. #5
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: vbYesNoAll (all)

    I can't find a discussion about the default default size of command buttons either. I don't think there is a "golden standard" here - Microsoft itself uses different sizes in different applications. The default height for command buttons in VBA userforms and in VB6 forms is 1/3 inch (24 points in VBA, 24.75 points in VB6), but the commmand buttons in most dialogs in Word, Excel etc. are about 1/4 inch high. The width depends on the length of the caption.

  6. #6
    Platinum Lounger
    Join Date
    Feb 2001
    Location
    Yilgarn region of Toronto, Ontario
    Posts
    5,453
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: vbYesNoAll (all)

    > 24 points in VBA

    That's what I'd used, based on a screen snapshot I pasted into Paint.exe.

    Odd. maybe I've been naughty and been dabbling in another forum somewhere. I do recall seeing it. I distinctly remember thinking at the time "I should save this post!".

  7. #7
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: vbYesNoAll (all)

    No need to use a snapshot - a command button has a Height property <img src=/S/evilgrin.gif border=0 alt=evilgrin width=15 height=15>

  8. #8
    Platinum Lounger
    Join Date
    Feb 2001
    Location
    Yilgarn region of Toronto, Ontario
    Posts
    5,453
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: vbYesNoAll (all)

    Yabbut (sounding more like a Canadian every day), I wanted the height of a regular Windows command button, not one of my own drag-from-toolbox efforts.

    I figured too I'd get the height/width of the original MsgBox form.

    Or do you know something I don't know? (Philosophical question, I know, otherwise why would I bother posing the question...)

  9. #9
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: vbYesNoAll (all)

    From
    <hr>> 24 points in VBA

    That's what I'd used, based on a screen snapshot I pasted into Paint.exe.<hr>
    I mistakenly concluded that you had measured the height of a VBA command button in Paint.

    I'm sure there are methods involving Windows API functions to retrieve the height of command buttons in dialog boxes etc., but I don't know how to do that.

    For philosophical questions I refer you to Donald Rumsfeld:
    <hr>There are known knowns; there are things we know we know. We also know there are known unknowns; that is to say we know there are some things we do not know. But there are also unknown unknowns - the ones we don't know we don't know.<hr>

  10. #10
    Platinum Lounger
    Join Date
    Feb 2001
    Location
    Weert, Limburg, Netherlands
    Posts
    4,812
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: vbYesNoAll (all)

    Just for fun.
    You can access the text on the buttons of a messagebox uning API trickery.
    I implemented that on the attached workbook.
    Jan Karel Pieterse
    Microsoft Excel MVP, WMVP
    www.jkp-ads.com
    Professional Office Developers Association

  11. #11
    Platinum Lounger
    Join Date
    Feb 2001
    Location
    Yilgarn region of Toronto, Ontario
    Posts
    5,453
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: vbYesNoAll (all)

    Thanks. That's a real, live Windows MsgBox being tailored, right? But it's done through an API call and "MessageBox" rather than a VBA "MsgBox"; is that correct?

  12. #12
    3 Star Lounger
    Join Date
    Aug 2001
    Location
    Jeddah, Saudi Arabia
    Posts
    243
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: vbYesNoAll (all)

    In my systems I try and keep the height of buttons approximately the same as the height of the arrow mouse pointer. That works ot at 345 units in VB6.

    I've looked at a few of the MS buttons and I think they are doing the same thing although I can't be sure. Bill hasn't shared his thoughts on this with me.

    Our users seem to like this, none of them have complained at least.

    Regards,
    Kevin Bell

  13. #13
    Platinum Lounger
    Join Date
    Nov 2001
    Location
    Melbourne, Victoria, Australia
    Posts
    5,016
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: vbYesNoAll (all)

    Chris

    I don't know how your C++ is, but you might be able to make use of A drop-in replacement for MessageBox().

    Short description:
    MessageBox() is useful when you want to ask the user a Yes/No question to get confirmation before performing some action. If your application is performing the action over and over again, it can be useful to have additional "Yes to All" and "No to All" buttons.
    The following articles describe replacements for MessageBox() with extra buttons for "Yes to All" and "No to All"


    I think it's the kind of thing you have in mind:
    <IMG SRC=http://www.codeproject.com/dialog/CRHYesNoToAllDialog/CRHYesNoToAllDialog.jpg>

    Alan

  14. #14
    Platinum Lounger
    Join Date
    Feb 2001
    Location
    Yilgarn region of Toronto, Ontario
    Posts
    5,453
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: vbYesNoAll (all)

    > I don't know how your C++ is

    Thanks, Alan,

    At a pinch I can deduce logic from written code, just by reading it. Once you send me my C++ compiler (CD will do fine), I'd be able to compile it, too (grin!).

    It's worth going through the logic after the specs to see how he does it, after which I could translate it to VBA.

  15. #15
    Platinum Lounger
    Join Date
    Nov 2001
    Location
    Melbourne, Victoria, Australia
    Posts
    5,016
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: vbYesNoAll (all)

    You may have noticed I chase <img src=/S/free.gif border=0 alt=free width=30 height=15>bies, Chris. There's a whole slew of Free C / C++ Compilers and Interpreters to choose from, some very small. Take your pick!

    Sing out if you need any of the code, syntax etc. explained. I can't give any assurances on translations to VB though; VB being my non-native tongue and all. <img src=/S/grin.gif border=0 alt=grin width=15 height=15>

    Alan

Page 1 of 2 12 LastLast

Posting Permissions

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