Academic Tutorials



English | French | Portugese | German | Italian
Home Advertise Payments Recommended Websites Interview Questions FAQs
News Source Codes E-Books Downloads Jobs Web Hosting
Chats

Visual Basic Tutorial
Introduction to VB
Building a Visual Basic Application
Writing the Codes in VB
Working With Controls
Managing Visual Basic Data
Working With Variables
Controlling Program Flow
More on Program Control
Looping in VB
Introduction to VB Function
Creating VB Function For MS Excel
Arrays in VB
Working With Files
Creating Multimedia Applications in VB
Creating database applications in VB
Creating VB database applications using ADO control

HTML Tutorials
HTML Tutorial
XHTML Tutorial
CSS Tutorial
TCP/IP Tutorial
CSS 1.0
CSS 2.0
HLML
XML Tutorials
XML Tutorial
XSL Tutorial
XSLT Tutorial
DTD Tutorial
Schema Tutorial
XForms Tutorial
XSL-FO Tutorial
XML DOM Tutorial
XLink Tutorial
XQuery Tutorial
XPath Tutorial
XPointer Tutorial
RDF Tutorial
SOAP Tutorial
WSDL Tutorial
RSS Tutorial
WAP Tutorial
Web Services Tutorial
Browser Scripting
JavaScript Tutorial
VBScript Tutorial
DHTML Tutorial
HTML DOM Tutorial
WMLScript Tutorial
E4X Tutorial
Server Scripting
ASP Tutorial
PERL Tutorial
SQL Tutorial
ADO Tutorial
CVS
Python
Apple Script
PL/SQL Tutorial
SQL Server
PHP
.NET (dotnet)
Microsoft.Net
ASP.Net
.Net Mobile
C# : C Sharp
ADO.NET
VB.NET
VC++
Multimedia
SVG Tutorial
Flash Tutorial
Media Tutorial
SMIL Tutorial
Photoshop Tutorial
Gimp Tutorial
Matlab
Gnuplot Programming
GIF Animation Tutorial
Scientific Visualization Tutorial
Graphics
Web Building
Web Browsers
Web Hosting
W3C Tutorial
Web Building
Web Quality
Web Semantic
Web Careers
Weblogic Tutorial
SEO
Web Site Hosting
Domain Name
Java Tutorials
Java Tutorial
JSP Tutorial
Servlets Tutorial
Struts Tutorial
EJB Tutorial
JMS Tutorial
JMX Tutorial
Eclipse
J2ME
JBOSS
Programming Langauges
C Tutorial
C++ Tutorial
Visual Basic Tutorial
Data Structures Using C
Cobol
Assembly Language
Mainframe
Forth Programming
Lisp Programming
Pascal
Delphi
Fortran
OOPs
Data Warehousing
CGI Programming
Emacs Tutorial
Gnome
ILU
Soft Skills
Communication Skills
Time Management
Project Management
Team Work
Leadership Skills
Corporate Communication
Negotiation Skills
Database Tutorials
Oracle
MySQL
Operating System
BSD
Symbian
Unix
Internet
IP-Masquerading
IPC
MIDI
Software Testing
Testing
Firewalls
SAP Module
ERP
ABAP
Business Warehousing
SAP Basis
Material Management
Sales & Distribution
Human Resource
Netweaver
Customer Relationship Management
Production and Planning
Networking Programming
Corba Tutorial
Networking Tutorial
Microsoft Office
Microsoft Word
Microsoft Outlook
Microsoft PowerPoint
Microsoft Publisher
Microsoft Excel
Microsoft Front Page
Microsoft InfoPath
Microsoft Access
Accounting
Financial Accounting
Managerial Accounting
Network Sites


Working With Controls

Previoushome Next





A D V E R T I S E M E N T

The Control Properties

Before writing an event procedure for control to response to a user's input, you have to set certain properties for the control to determine its appearance and how it will work with the event procedure and you can also set the properties of the controls in the properties window or at runtime.


Above figure is a typical properties window for a form. You can rename the form caption to any name that you like best and in the properties window, the item appears at the top part is the object currently selected (in the figure above, the object selected is Form1). At the bottom part, the items listed in the left column represent the names of various properties associated with the selected object while the items listed in the right column represent the states of the properties and properties can be set by highlighting the items in the right column then change them by typing or selecting the options available. For example, in order to change the caption, just highlight Form1 under the name Caption and change it to the other names. You may also try to alter the appearance of the form by setting it to flat or 3D. Other things you can do are to change its background and foreground color, change the font type and font size, enable or disable minimize and maximize buttons and etc.

You can also change the properties at runtime to give special effects such as change of color, animation effect and shape and so on. For example the following code will change the form color to red every time the form is loaded and VB uses hexadecimal system to represent the color. You can check the color codes in the properties windows which are showed up under BackColor and ForeColor.

Private Sub Form_Load()
Form1.Show
Form1.BackColor = &H000000FF&
End Sub



Handling some of the common controls

1.The Text Box

The text box is the standard control that is used to receive input from the user and also to display the output. It can handle string (text) and numeric data but not pictures or images.
String in a text box can be converted to a numeric data by using the function Val(text) and the following example illustrates a simple program that processes the inputs from the user.

In this program, two text boxes are inserted into the form together with a few labels and the two text boxes are used to accept inputs from the user and one of the labels will be used to display the sum of two numbers that are entered into the two text boxes. Besides,using the plus operator a command button is also programmed to calculate the sum of the two numbers.

Private Sub Command1_Click()

�To add the values in text box 1 and text box 2
Sum = Val(Text1.Text) + Val(Text2.Text)
�To display the answer on label 1
Label1.Caption = Sum

End Sub



2.The Label

The label is a very useful control for Visual Basic, as it is not only used to provide instructions and guides to the users, it can also be used to display outputs and one of its most important properties is Caption. Using the syntax label.Caption, it can display numeric and text data . You can change its caption in the properties window and also at the runtime.




3.The Command Button

The command button is a very important control as it is used to execute commands and it displays an illusion that the button is pressed when the user click on it. The most common event associated with the command button is the Click event, and the syntax for the procedure is as follows:

Private Sub Command1_Click ()

Statements

End Sub



4.The Picture Box

The Picture Box is one of the controls that used to handle graphics and you can load a picture at design phase by clicking on the picture item in the properties window and select the picture from the selected folder. You can also load the picture at runtime using the LoadPicture method and for example,the statement will load the picture grape.gif into the picture box.

Picture1.Picture=LoadPicture ("C:\VB program\Images\grape.gif")



5.The Image Box

The Image Box is another control that handles images and pictures and it functions almost identically to the picture box. However, there is one major difference, the image in an Image Box is stretchable, which means it can be resized and this feature is not available in the Picture Box. Similar to the Picture Box,to load the picture it can also use the LoadPicture method. For example, the statement loads the picture grape.gif into image box.

Image1.Picture=LoadPicture ("C:\VB program\Images\grape.gif")



6.The List Box

The function of the List Box is to present a list of items where the user can select and click the items from the list. In order to add items to the list, we can use the AddItem method and for example, if you wish to add a number of items to list box 1, you can key in the following statements

Private Sub Form_Load ( )

List1.AddItem �Lesson1�
List1.AddItem �Lesson2�
List1.AddItem �Lesson3�
List1.AddItem �Lesson4�
End Sub

Note:The items in the list box can be identified by the ListIndex property and the value of the ListIndex for the first item is 0, the second item has a ListIndex 1, and the second item has a ListIndex 2 and so on




7.The Combo Box

The function of the Combo Box is also to present a list of items where the user can select and click the items from the list. However, the user needs to click on the small arrowhead on the right of the combo box to see the items which are presented in a drop-down list and in order to add items to the list, you can also use the AddItem method. For example, if you wish to add a number of items to Combo box 1, you can key statements as follows

Private Sub Form_Load ( )

Combo1.AddItem �Item1�
Combo1.AddItem �Item2�
Combo1.AddItem �Item3�
Combo1.AddItem �Item4�

End Sub



8.The Check Box

The Check Box control lets the user to unselect or select an option. When the Check Box is checked, its value is set to 1 and when it is unchecked, the value is set to 0 and you can include the statements Check1.Value=1 to mark the Check Box and Check1.Value=0 unmark the Check Box, and use them to initiate certain actions. For example, the program will change the background color of the form to red when the check box is unchecked and when the check box is checked it will change to blue. You will learn about the conditional statement If�.Then�.Elesif in later lesson and vbBlue and VbRed are color constants and BackColor is the background color property of the form.

Private Sub Check1_Click ()

If Check1.Value = 0 Then
Form1.BackColor = vbRed
ElseIf Check1.Value = 1 Then
Form1.BackColor = vbBlue
End If

End Sub



9.The Option Box

The Option Box control also lets the user select one of the choices. However, two or more Option Boxes must work together because as one of the Option Boxes is selected and the other Option Boxes will be unselected. In fact, only one Option Box can be selected at one time. When an option box is selected, its value is set to �True� and its value is set to �False� when it is unselected. In the following example, the shape control is placed in the form together with six Option Boxes and when the user clicks on different option boxes, different shapes will appear. The values of the shape control are 0, 1, and 2,3,4,5 which will make it appear as a rectangle,an oval shape, a square , a rounded rectangle and a rounded square respectively.

Private Sub Option1_Click ( )
Shape1.Shape = 0
End Sub

Private Sub Option2_Click()
Shape1.Shape = 1
End Sub

Private Sub Option3_Click()
Shape1.Shape = 2
End Sub

Private Sub Option4_Click()
Shape1.Shape = 3
End Sub

Private Sub Option5_Click()
Shape1.Shape = 4
End Sub

Private Sub Option6_Click()
Shape1.Shape = 5
End Sub



10.The Drive List Box

The Drive ListBox is used to display a list of drives available in your computer and when you place this control into the form and run the program, you will be able to select different drives from your computer as shown in the following figure.




11.The Directory List Box

The Directory List Box is used to display the list of folders or directories in a selected drive. You will be able to select different directories from a selected drive in your computer as shown in Figure below,when you place this control into the form and run the program,




12.The File List Box

The File List Box is used to display the list of files in a selected directory or folder and when you place this control into the form and run the program, you will be able to a list of files in a selected directory as shown in Figurebelow



Be the first one to comment on this page.




  Visual Basic Tutorial eBooks
More Links » »
 
 Visual Basic Tutorial FAQs
More Links » »
 
 Visual Basic Tutorial Interview Questions
More Links » »
 
 Visual Basic Tutorial Articles
More Links » »
 
 Visual Basic Tutorial News
More Links » »
 
 Visual Basic Tutorial Jobs
More Links » »

Share And Enjoy:These icons link to social bookmarking sites where readers can share and discover new web pages.
  • blinkbits
  • BlinkList
  • blogmarks
  • co.mments
  • connotea
  • del.icio.us
  • De.lirio.us
  • digg
  • Fark
  • feedmelinks
  • Furl
  • LinkaGoGo
  • Ma.gnolia
  • NewsVine
  • Netvouz
  • RawSugar
  • Reddit
  • scuttle
  • Shadows
  • Simpy
  • Smarking
  • Spurl
  • TailRank
  • Wists
  • YahooMyWeb

Previoushome Next

Keywords: Working With Controls, asp net controls, vb net controls, visual basic controls, visual studio controls, visual basic net controls, windows forms controls, while windows was working with the control panel file, working with visual studio, working with control, c# controls, working with datagrid, repeater controls

HTML Quizzes
HTML Quiz
XHTML Quiz
CSS Quiz
TCP/IP Quiz
CSS 1.0 Quiz
CSS 2.0 Quiz
HLML Quiz
XML Quizzes
XML Quiz
XSL Quiz
XSLT Quiz
DTD Quiz
Schema Quiz
XForms Quiz
XSL-FO Quiz
XML DOM Quiz
XLink Quiz
XQuery Quiz
XPath Quiz
XPointer Quiz
RDF Quiz
SOAP Quiz
WSDL Quiz
RSS Quiz
WAP Quiz
Web Services Quiz
Browser Scripting Quizzes
JavaScript Quiz
VBScript Quiz
DHTML Quiz
HTML DOM Quiz
WMLScript Quiz
E4X Quiz
Server Scripting Quizzes
ASP Quiz
PERL Quiz
SQL Quiz
ADO Quiz
CVS Quiz
Python Quiz
Apple Script Quiz
PL/SQL Quiz
SQL Server Quiz
PHP Quiz
.NET (dotnet) Quizzes
Microsoft.Net Quiz
ASP.Net Quiz
.Net Mobile Quiz
C# : C Sharp Quiz
ADO.NET Quiz
VB.NET Quiz
VC++ Quiz
Multimedia Quizzes
SVG Quiz
Flash Quiz
Media Quiz
SMIL Quiz
Photoshop Quiz
Gimp Quiz
Matlab Quiz
Gnuplot Programming Quiz
GIF Animation Quiz
Scientific Visualization Quiz
Graphics Quiz
Web Building Quizzes
Web Browsers Quiz
Web Hosting Quiz
W3C Quiz
Web Building Quiz
Web Quality Quiz
Web Semantic Quiz
Web Careers Quiz
Weblogic Quiz
SEO Quiz
Web Site Hosting Quiz
Domain Name Quiz
Java Quizzes
Java Quiz
JSP Quiz
Servlets Quiz
Struts Quiz
EJB Quiz
JMS Quiz
JMX Quiz
Eclipse Quiz
J2ME Quiz
JBOSS Quiz
Programming Langauges Quizzes
C Quiz
C++ Quiz
Visual Basic Quiz
Data Structures Using C Quiz
Cobol Quiz
Assembly Language Quiz
Mainframe Quiz
Forth Programming Quiz
Lisp Programming Quiz
Pascal Quiz
Delphi Quiz
Fortran Quiz
OOPs Quiz
Data Warehousing Quiz
CGI Programming Quiz
Emacs Quiz
Gnome Quiz
ILU Quiz
Soft Skills Quizzes
Communication Skills Quiz
Time Management Quiz
Project Management Quiz
Team Work Quiz
Leadership Skills Quiz
Corporate Communication Quiz
Negotiation Skills Quiz
Database Quizzes
Oracle Quiz
MySQL Quiz
Operating System Quizzes
BSD Quiz
Symbian Quiz
Unix Quiz
Internet Quiz
IP-Masquerading Quiz
IPC Quiz
MIDI Quiz
Software Testing Quizzes
Testing Quiz
Firewalls Quiz
SAP Module Quizzes
ERP Quiz
ABAP Quiz
Business Warehousing Quiz
SAP Basis Quiz
Material Management Quiz
Sales & Distribution Quiz
Human Resource Quiz
Netweaver Quiz
Customer Relationship Management Quiz
Production and Planning Quiz
Networking Programming Quizzes
Corba Quiz
Networking Quiz
Microsoft Office Quizzes
Microsoft Word Quiz
Microsoft Outlook Quiz
Microsoft PowerPoint Quiz
Microsoft Publisher Quiz
Microsoft Excel Quiz
Microsoft Front Page Quiz
Microsoft InfoPath Quiz
Microsoft Access Quiz
Accounting Quizzes
Financial Accounting Quiz
Managerial Accounting Quiz
Testimonials | Contact Us | Link to Us | Site Map
Copyright ? 2008. Academic Tutorials.com. All rights reserved Privacy Policies | About Us
Our Portals : Academic Tutorials | Best eBooksworld | Beyond Stats | City Details | Interview Questions | Discussions World | Excellent Mobiles | Free Bangalore | Give Me The Code | Gog Logo | Indian Free Ads | Jobs Assist | New Interview Questions | One Stop FAQs | One Stop GATE | One Stop GRE | One Stop IAS | One Stop MBA | One Stop SAP | One Stop Testing | Webhosting in India | Dedicated Server in India | Sirf Dosti | Source Codes World | Tasty Food | Tech Archive | Testing Interview Questions | Tests World | The Galz | Top Masala | Vyom | Vyom eBooks | Vyom International | Vyom Links | Vyoms | Vyom World | Important Websites
Copyright ? 2003-2024 Vyom Technosoft Pvt. Ltd., All Rights Reserved.