Results 1 to 6 of 6

Thread: [RESOLVED] MsgBox option

  1. #1

    Thread Starter
    Member
    Join Date
    Feb 2006
    Posts
    49

    Resolved [RESOLVED] MsgBox option

    Guyz

    Is it possible to have a "OK" and "Cancel" option in a MsgBox or "Yes"

    or "No"?

    Or should I make a new form to do that?

    Thanks........

  2. #2
    PowerPoster jcis's Avatar
    Join Date
    Jan 2003
    Location
    Argentina
    Posts
    4,430

    Re: MsgBox option

    VB Code:
    1. MsgBox "OK/Cancel Message", vbOkCancel,"Title"
    2. MsgBox "Yes/No Message", vbYesNo,"Title"
    3. MsgBox "Yes/No/Cancel Message + Exclamation", vbYesNoCancel + VbExclamation,"Title"
    4. MsgBox "Critical Message", VbCritical,"Title"
    5. MsgBox "Info Message", VbInformation,"Title"

  3. #3
    Frenzied Member d3gerald's Avatar
    Join Date
    Jan 2006
    Posts
    1,348

    Re: MsgBox option

    and to support the above post by jcis, to identify what button is pressed, you can do it by
    VB Code:
    1. dim a
    2. a = msgbox "your prompt here", vbyesno,"title here"
    3. if a = vbyes then
    4.     'yes button is clicked
    5. else
    6.     'no button is clicked
    7. endif
    8. 'same is true with other button groups
    On error goto Trap

    Trap:
    in case of emergency, drop the case...

    ****************************************
    If this post has been resolved. Please mark it as "Resolved" by going through the "Thread Tools" above and clicking on the "Mark Thread Resolved " option.
    if a post is helpful to you, Please Rate it by clicking on the Rate link right below the avatar

  4. #4
    PowerPoster jcis's Avatar
    Join Date
    Jan 2003
    Location
    Argentina
    Posts
    4,430

    Re: MsgBox option

    a variable can be declared as VbMsgBoxResult

  5. #5

    Thread Starter
    Member
    Join Date
    Feb 2006
    Posts
    49

    Re: MsgBox option

    Thanks again guyz!!

  6. #6
    Hyperactive Member
    Join Date
    Jun 2005
    Location
    in Poland
    Posts
    390

    Re: [RESOLVED] MsgBox option

    Welcom

    Simple MsgBox additionally from CheckBox

    VB Code:
    1. Option Explicit
    2.  
    3. 'Copyright (C) 2005 DJK's Projects (DJK)
    4.  
    5. 'side of WWW, also in English language: [url]http://djkprojects.prv.pl/[/url]
    6. 'Contact:       [email][email protected][/email]
    7.  
    8. 'The author of example doesn't answer for possible damages called out the working following code.
    9.  
    10.  
    11. Private Const IDI_HAND = 32513&
    12. Private Const IDI_QUESTION = 32514&
    13. Private Const IDI_EXCLAMATION = 32515&
    14. Private Const IDI_ASTERISK = 32516&
    15.  
    16. Private Const MB_ICONHAND = &H10&
    17. Private Const MB_ICONQUESTION = &H20&
    18. Private Const MB_ICONEXCLAMATION = &H30&
    19. Private Const MB_ICONASTERISK = &H40&
    20.  
    21. Private Declare Function LoadIcon Lib "user32" Alias "LoadIconA" (ByVal hInstance As Long, ByVal lpIconName As Any) As Long
    22. Private Declare Function DrawIcon Lib "user32" (ByVal hdc As Long, ByVal X As Long, ByVal Y As Long, ByVal hIcon As Long) As Long
    23. Private Declare Function DestroyIcon Lib "user32" (ByVal hIcon As Long) As Long
    24. Private Declare Function MessageBeep Lib "user32" (ByVal wType As Long) As Long
    25.  
    26. Private Sub cmdNo_Click()
    27. Unload Me
    28. End Sub
    29.  
    30. Private Sub Form_Load()
    31. ShowMsgBox IDI_ASTERISK, MB_ICONASTERISK, "ExtraMsgBox", "http://djkprojects.prv.pl"
    32. End Sub
    33.  
    34. Private Sub ShowMsgBox(ByVal IconStyle As Long, ByVal BeepStyle As Long, ByVal Caption As String, ByVal Message As String)
    35. Dim hIcon As Long
    36.  
    37. With picIcon
    38.     .Top = 150
    39.     .Left = 150
    40.     .AutoRedraw = True
    41.     .BorderStyle = 0
    42.     .Width = 32 * Screen.TwipsPerPixelX
    43.     .Height = 32 * Screen.TwipsPerPixelY
    44. End With
    45.  
    46. With lblMsg
    47.     .Left = 870
    48.     .Top = 300
    49. End With
    50.  
    51. hIcon = LoadIcon(0&, IconStyle)
    52.  
    53. Call MessageBeep(BeepStyle)
    54.  
    55. Form1.Caption = Caption
    56. lblMsg.Caption = Message
    57.  
    58. Call DrawIcon(picIcon.hdc, 0, 0, hIcon)
    59. Call DestroyIcon(hIcon)
    60.  
    61. End Sub
    I know, I know, my English is bad, sorry .....

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