Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
74 views

Lecture 5

This document discusses the properties and uses of command buttons in Visual Basic forms and applications. It provides a table listing common command button properties like Caption, Style, Backcolor, Forecolor, Font, Visible, and Enabled. It also gives examples of using command buttons to display text in labels and textboxes when clicked, and includes code samples to demonstrate how to assign properties and write click event procedures.

Uploaded by

Osama Hayder
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
74 views

Lecture 5

This document discusses the properties and uses of command buttons in Visual Basic forms and applications. It provides a table listing common command button properties like Caption, Style, Backcolor, Forecolor, Font, Visible, and Enabled. It also gives examples of using command buttons to display text in labels and textboxes when clicked, and includes code samples to demonstrate how to assign properties and write click event procedures.

Uploaded by

Osama Hayder
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 9

Lecture 5 :Command button

Command
• It acts as a switch. To deal with tool
property> click on command button>
property window appear> change
setting of any desired property. Usually
change set its caption property to a
suitable string. To make the button
functional, the user should add some
code. To do this: click on command tool>
code form appears with click event
procedure. Write code in this event or
other events like press key event.
The most familiar properties that are needed for the command button are stated in
the table below.

Property Objective Code Stage of changing


Caption String appear on command commandno.caption=“any name” Design and run
style Determine the style of 1- graphical Design
command 0-standard
Backcolor Background color for command commandno.backcolor = Qbcolor(no.) Design and run
Forecolor Color of text written on label commandno.forecolor = Qbcolor(no.) Design and run
Font Font style, type and size Size: commandno..fonsize = no.
Style: italic
font bold
underline
Type : commandno.fontname = “arial”
Visible The label appear or disappear commandno.visible = true or false Design and run
Enabled The label enable or disable commandno.enable = true or false Design and run
Example: Design a form with label, such that when click on the
command button "name" your name appears on label (at
running stage) as shown in the figure below
• Private Sub Command1_Click()
• Label1.Caption = "Ahmad"
• End Sub
• Example: Design a form to appear your name and department in
textbox, when click on command button "name" and "department"
respectively so that you can clear these information when click on
command "clear" and stop project when click on command "exit"
Solution of example

Private Sub Form_load () Private Sub Command1_Click()


Command1.caption =“name” Text1.text=“ your name"
Command2.caption =“department” End Sub
Command3.caption = “clear” Private Sub Command2_Click()
Command4.caption = “END” Text1.text=“medical instrument engineer"
End sub End Sub
Private Sub Command3_Click()
Text1.text=" "
End Sub
Private Sub Command4_Click()
end
End Sub

You might also like