+ Reply to Thread
Results 1 to 6 of 6

Thread: Hiding Images via Macro

  1. #1
    Registered User
    Join Date
    11-17-2011
    Location
    australia
    MS-Off Ver
    2010
    Posts
    4

    Question Hiding Images via Macro

    Hi there, this is my first post here, just looking for some help with an assignment i've been given as my lecturer is useless.

    Sorry i meant to post this in Excel section.

    I have created a quiz with images that gives you point upon clicking the correct one, but the problem is you can click any image multiple times until you get the right one.

    I was looking for something that would work like this:

    Click Pic1 >
    Pic2, Pic3 and Pic4 all go invisible

    I know the macro command (.Visible = False) but im not sure how i would code this so it would work?

    Here's what my VB statement looks like at the moment

    Sub Picture6_Click()
    MsgBox "WRONG!", vbOKOnly, "Incorrect"
    Range("G73").Value = "0"
    End Sub
    _________________________________________________________
    Sub Picture7_Click()
    MsgBox "WRONG!", vbOKOnly, "Incorrect"
    Range("G73").Value = "0"


    End Sub
    _________________________________________________________
    Sub Picture8_Click()
    MsgBox "WRONG!", vbOKOnly, "Incorrect"
    Range("G73").Value = "0"


    End Sub
    _________________________________________________________
    Sub Picture9_Click()
    MsgBox "Correctamundo!", vbOKOnly, "Correct"
    Range("G73").Value = "2"


    End Sub
    And heres something i came up with (which encountered errors naturally).

    Sub Hide()
    If Picture6_Click = True Then
    Picture6.Visible = False
    ElseIf Picture7_Click() = True Then
    Picture7.Visible = False
    ElseIf Picture8_Click() = True Then
    Picture8.Visible = False
    Last edited by Sauc; 11-17-2011 at 03:16 AM.

  2. #2
    Valued Forum Contributor vlady's Avatar
    Join Date
    09-22-2011
    Location
    Philippines - Guimba-Nueva Ecija
    MS-Off Ver
    2010
    Posts
    784

    Re: Hiding Images via Macro

    How about

    Picture6.Enabled = False

    
    Sub Picture6_Click()
    MsgBox "WRONG!", vbOKOnly, "Incorrect"
    Range("G73").Value = "0"
    
    Picture6.Enabled = False
    
    End Sub
    Contributors to this forum do not get paid. They give their valuable time to help you solve your problem. That's why feel free to CLICK their STAR icon to say thank you -even the given idea/solution didn't really solve your queries. The time given to you deserves a small gratitude anyway.

    Dare to give a pencil to a child. http://www.blackpencilproject.org/

  3. #3
    Registered User
    Join Date
    11-17-2011
    Location
    australia
    MS-Off Ver
    2010
    Posts
    4

    Re: Hiding Images via Macro

    I tried this but i get an error
    "Run-time error '424':
    object required.

    Thanks for the help.

    NOTE: Sorry i've realised now that this is in the wrong section, it was intended for Excel but i wasnt paying enough attention
    My apologies :p
    Last edited by Sauc; 11-17-2011 at 03:18 AM.

  4. #4
    Valued Forum Contributor vlady's Avatar
    Join Date
    09-22-2011
    Location
    Philippines - Guimba-Nueva Ecija
    MS-Off Ver
    2010
    Posts
    784

    Re: Hiding Images via Macro

    Sorry didn't notice its a module

    try to move your codes to General
    then use
    private sub - end sub
    
    Private Sub Picture6_Click()
    Picture6.Enabled = False
    End Sub
    Contributors to this forum do not get paid. They give their valuable time to help you solve your problem. That's why feel free to CLICK their STAR icon to say thank you -even the given idea/solution didn't really solve your queries. The time given to you deserves a small gratitude anyway.

    Dare to give a pencil to a child. http://www.blackpencilproject.org/

  5. #5
    Valued Forum Contributor vlady's Avatar
    Join Date
    09-22-2011
    Location
    Philippines - Guimba-Nueva Ecija
    MS-Off Ver
    2010
    Posts
    784

    Re: Hiding Images via Macro

    Sampler to hide and unhide
    Attached Files Attached Files
    Contributors to this forum do not get paid. They give their valuable time to help you solve your problem. That's why feel free to CLICK their STAR icon to say thank you -even the given idea/solution didn't really solve your queries. The time given to you deserves a small gratitude anyway.

    Dare to give a pencil to a child. http://www.blackpencilproject.org/

  6. #6
    Registered User
    Join Date
    11-17-2011
    Location
    australia
    MS-Off Ver
    2010
    Posts
    4

    Re: Hiding Images via Macro

    Quote Originally Posted by vlady View Post
    Sampler to hide and unhide
    Took this and modified slightly.

    Heres how it is
    Private Sub CommandButton1_Click()

    Image1.Visible = True
    Image2.Visible = True
    Image3.Visible = True
    Image4.Visible = True

    End Sub

    Private Sub Image1_Click()
    MsgBox "WRONG!!", vbOKOnly, "Incorrect"
    Range("G73").Value = "0"

    Image2.Visible = False
    Image3.Visible = False
    Image4.Visible = False
    So when i click one the rest go invisible. The Command Box is to reset it and is going to be locked.

    Thanks a lot vlady :D

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.2.0