Welcome to Scribd, the world's digital library. Read, publish, and share books and documents. See more
Download
Standard view
Full view
of .
Look up keyword
Like this
2Activity
0 of .
Results for:
No results containing your search query
P. 1
Microsoft Visual Basic 6 (Intrinsic Control)

Microsoft Visual Basic 6 (Intrinsic Control)

Ratings: (0)|Views: 743|Likes:
Published by Abdul Majeed Khan
abdul.majeed.78@hotmail.com
abdul.majeed.78@hotmail.com

More info:

Published by: Abdul Majeed Khan on Dec 04, 2010
Copyright:Attribution Non-commercial

Availability:

Read on Scribd mobile: iPhone, iPad and Android.
download as DOC, PDF, TXT or read online from Scribd
See more
See less

12/04/2010

pdf

text

original

 
Visual Basic Intrinsic Control
Microsoft Visual Basic Intrinsic Controls
The Control Properties
Before writing an event procedure for the control to response to a user's input, you have toset certain properties for the control to determine its appearance and how it will work withthe event procedure. You can set the properties of the controls in the properties window orat runtime.
Common PropertiesDescription
Align/AlignmentReturns or sets a value that determines whether an object isdisplayed in any size anywhere on a form or whether it's displayedat the top, bottom, left, or right of the form and is automaticallysized to fit the form's width.AppearanceReturns or sets a value that determines the appearance of theobject.BorderStyleSets the border style for an object.NameThe name is used in code to identify an object.AutoSizeA control is automatically resized to display its entire contents.BackColor/ForeColorSet the background or foreground color of objectCaption/TextDisplay text in or on an object.Enable/VisualAn object is non respone or hidden from user action. (true/False)MouseIconeSet a custom mouse icon.MousePointerSet the mouse pointer from the list.LockDetermines whether a control can be edited.Width/Height/Top/LeftSet the width or height of object or set the distance from top orleft.ToolTipTextThe text display when mouse is paused over the control.TabIndexSet the tab order of an object within its parent form.FontSet the font size and style of object text.
Common EventsDescription
ClickOccurs when the user click a mouse button on object.DblClickOccurs when the user double click the mouse button on object.KeyUp/KeyDown/KeyPressOccurs when the user press any key through keyboard onobject.Keydown and KeyUp event to capture the function keys.MouseDown/MouseUp/MouseMoveOccurs when the user press a mouse button on object.GotFocusOccurs when an object receives the focus, either by user action,such as tabbing to or clicking the object, or by changing the focusin code using the
SetFocus
method.LostFocusOccurs when an object loses the focus, either by user action,such as tabbing to or clicking another object
 
Visual Basic Intrinsic Control
Example of KeyPress EventSyntaxPrivate Sub Form_KeyPress(
keyascii 
 
As Integer)End Sub
The KeyPress event syntax has these parts:
PartDescription
keyascii 
An integer that returns a standard numeric ANSI keycode.
Keyascii 
ispassed by reference; changing it sends a different character to theobject. Changing
keyascii 
to 0 cancels the keystroke so the objectreceives no character.
Example-01
Private Sub Text1_KeyPress(KeyAscii As Integer)MsgBox KeyAsciiEnd Sub
Example-02
Private Sub Text1_KeyPress(KeyAscii As Integer)If KeyAscii >= 48 And KeyAscii < 57 ThenMsgBox "You pressed Numeric Key. " + Chr(KeyAscii)KeyAscii = 0ElseIf KeyAscii >= 97 And KeyAscii <= 122 ThenMsgBox "You pressed Small character Key. " + Chr(KeyAscii)KeyAscii = 0ElseIf KeyAscii >= 65 And KeyAscii <= 90 ThenMsgBox "You pressed capital character Key. " + Chr(KeyAscii)KeyAscii = 0ElseMsgBox "Un-Know character." & KeyAsciiKeyAscii = 0End IfEnd Sub
Example of KeyDown/KeyUp EventSyntaxPrivate Sub
 
Form_KeyDown(
keycode 
 
As Integer
,
shift 
 
As Integer)
End SubThe KeyDown and KeyUp event syntaxes have these parts:
PartDescription
keycode 
A key code, such as
vbKeyF1
(the F1 key) or
vbKeyHome
(the HOME key).To specify key codes.
shift 
Capture the SHIFT, CTRL, and ALT keys at the time of the event. SHIFT key (vbShiftMask), CTRL key (vbCtrlMask), ALT key (vbAltMask).
Example-01
 
Visual Basic Intrinsic Control
Private Sub Text1_KeyUp(KeyCode As Integer, Shift As Integer)If (Shift And vbShiftMask) ThenMsgBox "You pressed Shift Key."ElseIf (Shift And vbAltMask) ThenMsgBox "You pressed Alt Key."ElseIf (Shift And vbCtrlMask) ThenMsgBox "You pressed Control Key."ElseIf KeyCode = vbKeyF2 ThenMsgBox "You pressed F2 key."End IfEnd Sub
Example of MouseMove/Up/Down EventPrivate Sub Form_MouseMove(
button 
As Integer
,
 
shift 
As Integer
,
 
As Single
,
 
AsSingle)
End SubThe Mouse event syntax has these parts:
PartDescription
button 
Indicating which buttons are pressed.(vbLeftButton,vbRightButton,vbMiddleButton)
,
A number that specifies the current location of the mouse pointer. The
and
values are always expressed in terms of the coordinate system setby the
ScaleHeight
,
ScaleWidth
,
ScaleLeft
, and
ScaleTop
properties ofthe object.
Example-01
Private Sub Text1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y AsSingle)If Button = vbRightButton ThenMsgBox "You press mouse right button."End IfEnd Sub
Example-02
Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y AsSingle)Print "Mouse x position:" & X & "Mouse y position:" & YEnd Sub

Activity (2)

You've already reviewed this. Edit your review.
1 thousand reads
1 hundred reads

You're Reading a Free Preview

Download
scribd
/*********** DO NOT ALTER ANYTHING BELOW THIS LINE ! ************/ var s_code=s.t();if(s_code)document.write(s_code)//-->