Hey, one simple question: how to call Image1_click event form module?

Recommended Answers

All 4 Replies

not like that. what will happen in click event that write in module. plz check it.

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

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.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.