Solved

Calling a module in a form.

Posted on 1998-09-09
2
185 Views
Last Modified: 2010-04-30
How do you get a module to run in a form. Here is the code that I have in a module "If (KeyAscii = 13) Then SendKeys "{TAB}"".  I don't want to type it everytime and want to call it from a procedure.
0
Comment
Question by:matthewkwp
2 Comments
 
LVL 5

Accepted Solution

by:
yronnen earned 50 total points
ID: 1433863
in the module write
public sub ButtonClick(KeyAscii)
If (KeyAscii = 13) Then SendKeys "{TAB}"
end sub

in your keydown event on every form write
ButtonClick(KeyAscii)


0
 
LVL 1

Expert Comment

by:bharris1
ID: 1433864
First you can always 'copy and paste' code.  This has become one of my favorite helpful tips for coding.

Second, the KeyDown event doesn't give you the Ascii code for the key pressed it's in the KeyPress event.

Third, you should be able to call it like anything else.

IN FORM:
Private Sub Text1_KeyPress(KeyAscii As Integer)
    MyProcedure KeyAscii
End Sub

IN MODULE:
Public Sub MyProcedure(KeyAscii As Integer)
    If (KeyAscii = 13) Then SendKeys "{TAB}"
End Sub


0

Featured Post

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now