Private Sub Command1_Click()
Call sohel(Image1)
End Sub

Module 1

Public Function sohel(a As Image)
a.Visible = False
End Function

What do you actually want to happen when you click the command button? Will the image "load" from somewhere? Or change?

You cannot use a function to change yje visible factor of an image.

If you want to click the button then

Private Sub Command1_Click()
if image1.visible=false then 
 image1.visible=true
elseif  image1.visible=true then
 image1.visible=false
end if
end sub

Edited 7 Years Ago by Jupiter 2: if end if tags

Jupiter2,

Here is a way to shorten you comman1_click code...

Image1.Visible = Not Image1.Visible

Just a piece of knowledge I thought I would pass along.

As for the OP, deftones, Jupiter2 has most of what you need to accomplish what you want but allow me to clarify more...

As of right now I cannot see a way to directly call an images click event but you can create a public sub proceedure in your form and call it...

in module...

Call Form1.MySub

In Form...

Public Sub MySub()
Call Image1_Click
End Sub

However, if you were to call a command button then you could call it directly by...

Form1.Command1.Value = True

Good Luck

Oh, now it's clear what I did wrong - I forgot to declare "public", therefore wasn't able to call that sub from module. Thanks guys.

This question has already been answered. Start a new discussion instead.