Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Mouseove in module

Status
Not open for further replies.

Omono

MIS
Apr 20, 2001
24
0
0
US
I have a number of forms each with the following mouseover code:

Private Sub Form_MouseMove(Button As Integer, shift As Integer, _
x As Single, y As Single)
frmInfoActMPH.Visible = False
End Sub
Private Sub Image1_MouseMove(Button As Integer, shift As Integer, _
x As Single, y As Single)
frmInfoActMPH.Visible = True
End Sub

It works fine. I want to put the code in a module and pass the form names to it but just copying the above code into the module will not work. Thanks in advance for any help.
 
In modules you can have subs, functions etc, but not this you want. The code for these events (Form_MouseMove and Image1_MouseMove) can be placed only in there; {private sub ... end sub}.



If the forms are the same with little diffrences, write this code once, and create them at run time. I say this because I think you want to have less code written.
 
Actually private can be used in any module as long as you call it from a different part of the module which should be public if u need to call it from a form. I always adopt this method as it controls your code, by that I mean it is a form of encapsulation without using classes e.g.
in the module
Code:
Private booSaleComplete As Boolean

Private Sub setSaleComplete(saleDone As Boolean)
    booSaleComplete = saleDone
End Sub

Public Sub theSaleDone(theSaleComplete As Boolean)
    setSaleComplete (theSaleComplete)
End Sub

Public Function saleDone() As Boolean
    saleDone = booSaleComplete
End Function

hope this helps
 
Sorry perhaps I should have added to that, there must be variables outside of the functions (usually at the top) to store the information that you will need later, just because they are private doesn’t mean they will loose there value. in the above case i would just write in a form where i need to know if a sale was done:
Code:
if saleDone then
   do this
else
   do that
end if
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top