Results 1 to 4 of 4

Thread: MsgBox with Yes/No

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Jan 2000
    Location
    Greenville
    Posts
    73

    Post

    Fro some reason this code will not work where I have it. it is just a message box with yesno and when yes is no is clicked I want it to exit the sub. Am i missing something:

    Dim iAnswer As Integer

    MsgBox "Did You Save Your New Changes?", vbYesNo + vbInformation, "Close Inventory History Page"
    If iAnswer = vbno Then
    Cancel = True
    Exit Sub
    End If

  2. #2
    Member
    Join Date
    Jun 1999
    Posts
    52

    Post

    Try this:
    Code:
    Dim iAnswer As Integer 
    
    iAnswer= MsgBox "Did You Save Your New Changes?", vbYesNo + vbInformation, "Close Inventory History Page" 
    If iAnswer = vbno Then 
    Cancel = True 
    Exit Sub 
    End If
    -Adam
    Yahoo!: _eclipsed_
    ICQ:18534929

  3. #3
    PowerPoster Chris's Avatar
    Join Date
    Jan 1999
    Location
    K-PAX
    Posts
    3,238

    Post

    Why we need the iAnswer?

    If MsgBox("Did You Save Your New Changes?", vbYesNo + vbInformation, "Close Inventory History Page") = vbNo Then
    Cancel = True
    Exit Sub
    End If


    Try this:
    Code:
    Dim iAnswer As Integer 
    
    iAnswer= MsgBox "Did You Save Your New Changes?", vbYesNo + vbInformation, "Close Inventory History Page" 
    If iAnswer = vbno Then 
    Cancel = True 
    Exit Sub 
    End If

  4. #4
    Member
    Join Date
    Jan 2000
    Location
    Singapore
    Posts
    59

    Post

    Hai VBAmateur,
    You are using msgbox statement it will not return
    any values.

    what chris is saying is correct.Chris is using a msgbox
    function.From that only you can expect a value ,to react
    accordingly.


    Dim response 'declare a variable to hold the value.

    response=msgbox(-------------)
    if response=vbyes then
    --do something

    else

    cancel=true

    end if



    thanks
    karun

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