Results 1 to 6 of 6

Thread: aarrgghh

  1. #1

    Thread Starter
    Fanatic Member zmerlinz's Avatar
    Join Date
    May 2000
    Location
    in a world where the sun always shines on the bloody tv!!
    Posts
    604

    Unhappy

    hi,

    i have the following code to shut down the computer but when i click on no it still shuts down the computer


    msgbox "do you want to shut down the computer", vbYesNo
    if vbYes then
    CODE TO SHUT DOWN COMPUTER
    end if



    please help

    Merlin ?

    Some people have told me they don't think a fat penguin really embodies the grace of Linux, which just tells me they have never seen a angry penguin charging at them in excess of 100mph. They'd be a lot more careful about what they say if they had.
    -- Linus Torvalds

    [Galahtech.com] | [My Site] | [Fishsponge] | [UnixForum.co.uk]

  2. #2

  3. #3
    Hyperactive Member
    Join Date
    Mar 2000
    Location
    Boulder, Colorado, USA
    Posts
    325
    needs to be like this:

    Code:
    If (MsgBox("do you want to shut down the computer", vbYesNo) = vbYes) Then
    
      '' Code to shutdown
    
    End If
    -Shickadance

  4. #4

    Thread Starter
    Fanatic Member zmerlinz's Avatar
    Join Date
    May 2000
    Location
    in a world where the sun always shines on the bloody tv!!
    Posts
    604
    Thanks Guys !!

    Some people have told me they don't think a fat penguin really embodies the grace of Linux, which just tells me they have never seen a angry penguin charging at them in excess of 100mph. They'd be a lot more careful about what they say if they had.
    -- Linus Torvalds

    [Galahtech.com] | [My Site] | [Fishsponge] | [UnixForum.co.uk]

  5. #5
    Fanatic Member
    Join Date
    Mar 2000
    Location
    That posh bit of England known as Buckinghamshire
    Posts
    658
    While the above two examples are correct, i think it is a good idea of getting into the habit of placing the reult into a variable.

    This will let you test diferetent values that are returned when you move onto more than two buttons.

    Code:
    Dim lResult As Long
    
    lResult = MsgBox ("Shut Down ?", vbYesNo)
    
    If lResult = vbYes THen
      'shut down
    End If
    Iain, thats with an i by the way!

  6. #6
    Junior Member
    Join Date
    Jun 2000
    Location
    Manchester, England
    Posts
    28
    Just so you're clear:

    MsgBox is a function, it returns a result (an integer) which relates to the button the user clicked or pressed. Therefore you have to evaluate the return value from the function and execute code accordingly.

    vbYes
    vbNo
    vbCancel

    etc. etc.

    We watch in reverence as Narcissus is turned to a flower.

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