Learning about Parameters (Continue)
Look at the first line of the Command Button's KeyDown Event:
Private Sub Command1_KeyDown(KeyCode As Integer, Shift As Integer)
As you can see, the KeyDown event gets two parameters:
The KeyCode parameter, and the Shift parameter, both are
Integer type.
Every Sub can get no parameters (like the Click event), can get
one parameter (like the KeyPress event) or can get more than
one parameter.
If a sub is getting more than one parameter, the parameters
have to be separated with commas.
For example:
Private Sub MySubName (Parameter1 As String, Parameter2 As Integer, Parameter3 As String)
Lets check out the KeyDown event's parameters.
The first is KeyCode, and it holds the KeyCode value
of the pressed key.
The KeyCode value is usually different from the Ascii Value.
The different between KeyCode and Ascii, is that
every character has Ascii value (for example G, @, |, =, and more)
but there are some keys that don't represent any character, for example:
Alt, F4, Ctrl, The left arrow key.
These keys don't have Ascii value, but they have KeyCode value.
For example, the KeyCode value of the Ctrl Key is 17.
Ascii represent characters, while KeyCode represent Keyboard's keys.
Because of that, the characters "a" and "A" have different Ascii value,
but they have the same KeyCode value, because the same key
is typing "a" and "A".
The second parameter is Shift, and its value helps you
to determine if the user has pressed the Shift, Ctrl or Alt keys.
The Shift holds the value 1 if the user has pressed the Shift key,
the value 2 if the user has pressed the Ctrl Key,
and the value 4 if the user has pressed the Alt Key.
If the user has pressed the Alt key and the Shift key together,
the Shift value will be 4 (for the Alt key) + 1 (for the Shift key) = 5
Examples:
If the user has pressed the "A" key,
The KeyCode parameter will hold the number 65, and
the Shift parameter will hold the value 0.
If the user has pressed Shift and "A" together,
The KeyCode parameter will hold the number 65, and
the Shift parameter will hold the value 1.
The KeyUp event's parameters are the same as the KeyDown event's parameters.
Popular Posts
- 
Creating DataTable Visual Basic allows us to create our own Tables and work with them. The DataTable is an in-memory representation of a blo...
- 
JSP pages are high level extension of servlet and it enable the developers to embed java code in html pages. JSP files are finally compiled ...
- 
The SQL AND clause is used when you want to specify more than one condition in your SQL WHERE clause, and at the same time you want all con...
- 
Lab exercises and homeworks: * Things to check before you start the lab * Chapter 3 (Class #1, Jan. 16th homework) o Exerc...
- 
Simple Binding Data Binding Data Binding is binding controls to data from the database. With data binding we can bind a control to a partic...
- 
Methods A Method is a procedure built into the class. They are a series of statements that are executed when called. Methods allow us to han...
- 
Generating the Server Response: HTTP Status Codes : When a Web server responds to the request from the browser or other Web client, the r...
- 
<%@page contentType="text/html" import="java.util.*" %> <!-- http://www.roseindia.net/jsp --> ...
- 
CONSTANTS,VARIABLES AND KEYWORDS: CONSTANTS: Two types of constants those are: a)primary constants b)secondary constants a)In primary consta...
- 
Interfaces Interfaces allow us to create definitions for component interaction. They also provide another way of implementing polymorphism. ...
 
 
 
 
 
 
Same old matter. Copying everything. Use some original matter. Stupid
ReplyDelete