none
VBS script is not working. RRS feed

  • General discussion

  • So I am doing a simple script for a school project, can you help me fix the "expected statement" error?
    x=msgbox("Hello. Make sure you dispose of this computer properly. You can donate to a local school, retirement home, charitable organization, or a community center. You can recycle it or resell it. Let's protect our enviornment one piece of tech at a time. Our tech. Our future. Our job.",1,"Proper Care")
    If vbCancel then
        CreateObject("WScript.Shell").Run("http://bestanimations.com/Military/Explosions/earth-explosion-animated-gif-2.gif")
        If vbOK then
            CreateObject("WScript.Shell").Run("https://www.cta.tech/Consumer-Resources/Greener-Gadgets/Recycle-Electronics.aspx")
            x=msgbox("If you don't, we might have a horrible future.",16,"Help the environment")
    	EndIf

    • Changed type Bill_Stewart Wednesday, November 29, 2017 11:52 PM
    • Moved by Bill_Stewart Wednesday, November 29, 2017 11:52 PM This is not "do my homework project for me" forum
    Thursday, October 26, 2017 12:28 PM

All replies

  • "EndIf" should be "End If", and you'll need 2 of them, one for the "If vbOk then" and one for the "If vbCancel then"

    That should sort you.

    Thursday, October 26, 2017 12:44 PM
  • You are using x for the results of the msgbox and never using it.

    The if syntax is wrong.

    Look up and study the syntax for your VBS elements until you understand hw they work.

    The results of a messagebox are testable so you need to test the results.


    \_(ツ)_/

    Thursday, October 26, 2017 12:48 PM
  • Sorry but this is not the right place to ask for help with homework questions. Ask your instructor.

    -- Bill Stewart [Bill_Stewart]

    Thursday, October 26, 2017 2:26 PM
  • Not homework, Its for a project and its more or less for fun. Its not for points.
    Thursday, October 26, 2017 2:30 PM
  • I refer the honorable gentleman to the answers already provided.

    -- Bill Stewart [Bill_Stewart]

    Thursday, October 26, 2017 2:40 PM