Components
of .net framework
.Net framework provides multiple
advantages to the programmers in comparison to the advantages provided by other
platforms. Micro-soft has integrated various modern as well as existing
technologies of application development in .net frame work. These technologies
are highly efficient for modern as well as future business application. There
are following components of .net framework
11. .net class library
22. Common language run time
33.Dynamic language run time
44.Application domains
55..net frame work security
66. Cross language interoperability
77.Side by side execution
88.Common type system
1..net class
library
.net frame work contains multiple
classes that are readily available for developers. The class in the FCL (frame
work class library) are grouped under multiple namespaces
2.Common
language run time
CLR provides interoperability between
different languages, like C#, VB, Visual C++ by providing a common environment
for the execution of code orientation of these languages.
3.Dynamic
language runtime
DLR provides to execute dynamic language
on .net frame work by adding some special services to the CLR
4.
Applications domains
It is used to isolate the process of
different applications and can be defined by .net frame work.
5. .net
frame work security
.net frame work provides multiple tools
that can be used by developers to protect the resources and code from
unauthorized users.
6.Cross
language interoperability
Object or compiled code of one language
can be used in other .net compatible language
7. side by
side execution
In some application we can use multiple
versions of CLR simultaneously.
8.Common type system
CTS is used to maintain data integrity across the code written in different.net compliant languages CTS also used to present data loss when a type in one language transfers data to its equivalent type in other languages.
Directives
The vb.net compiler directives give
instructions to the compiler to pre-process the information before the actual
compilation starts. All these directives begin with #, and only white space
characters may appear before a directive on a line. These directives are not
statements.
Vb.net compiler does not have a separate preprocessor. However, the
directives are processed as if there was one.
Vb.net provides the following set of
compiler directives.
-
The
# const Directive
-
The
# external source directive
-
The
#if … then… # else directives
-
The
# region directive
The #const
Directive
This directive defines conditional
compiler constants.
#const const
name = expression
Const name –
specifies the name of the constant required.
#const state
=” Tamil Nadu”
The following code demonstrates a
hypothetical use of the directive
Module
module1
#const
age=true
Sub main()
#if age then
Console.WriteLine(“you
are welcome to the robotics club”)
#end if
Console.ReadKey()
End sub
End module
The #External
source directive
The directive is used for indicating a
mapping between specific lines of source code and text external to the source.
#External
source (“c:\directives.vb”0
Console.writeline
“This is the external code”
#end
external source
The #if…
then… else Directives
The Directive conditionally compiles
selected blocks o code.
#const
targetos=”linux”
#if targeros
=”windows 7” then
Windows 7
specific code
#else if
targetos =”windows xp” then
Windows xp
specific code
#else
Code for other OS
#end if
# region
directive
The directive helps in collapsing and
hiding sections of code.
#region
Track bar
control
The track bar control resembles the
scroll bar because it provides a slider, analogous to the thumb of the scroll
bar, for the user to position with the mouse or keyboard. The relative position
of the slider is exposed as the value of the control. Unlike the scroll bar,
there are no separate horizontal and vertical versions of the trackbar
control. Instead, an orientation property can have the value of either
horizontal or vertical. You can also change the background color using the back
color property.
A horizontal track bar is similar to a
horizontal scroll bar in that the value property increases as the slider is
moved from left to right. In contrast, the vertical track bar is opposite the
vertical scroll bar, the value of a vertical scroll bar increases from top to
bottom, but the value of a vertical scroll bar increases from top to bottom,
but the value of a vertical track bar increases from bottom to top. This makes
sense if you think about the primary use of the two controls a scroll bar is
usually used for positioning, but a track bar is generally used for setting a
value.
An accessible name is the name of a user
interface element. Its value is a big part of what is communicated to users of
assistive technology. Without it, people who rely on those technologies would
have difficulty understanding or interact with much of the content on the
page.
The AccessibleRole property
describes what kind of user interface element an object is. If the control's role
cannot be determined, the AccessibleRole property is set to Default.
For more information about the properties of accessible objects
the cursor is an indicator used to
show the current position for user interaction on a computer monitor or other
display device
Orientation: sets a value indicating the horizontal or the vertical orientation of the track bar.
Small change: sets the value added to or subtracted from the Value property when the track bar is moved a small distance.
Tick frequency:
if the range is from 0 to 10, and the Tick Frequency is 2, there will be
one tick for every 2 increments in the range.
Tick style: sets a
value indicating how to display the tick marks on the track bar.
Allow drop: sets a value indicating whether this element can
be used as the target of a drag-and-drop operation.
Autosize: automatically
adjust the height to fit the text.
A context menu is a pop-up menu that provides shortcuts
for actions, the software developer anticipates the user might want to take.
Large change: sets the value added to or
subtracted from the Value property when the track bar is moved a large distance
Tab index: The element can be
focused by pressing the Tab
key
ADO.NET
ADO.NET is a data access technology from a micro soft .net framework, which provides communication between relational and
non-relational systems through a common set of components. ADO.NET uses built
for a disconnected architecture, so it enables truly disconnected data access
and data manipulation through its data set. Object, which is completely
independent from the data source.
The four
objects from the .NET frame work provide the functionality of data providers in
the ADO.NET. They are connection object, command object, Data Reader object and
data adapter object.
The connection object provides physical connection to the data source.
The command object uses to perform SQL statement or stored procedure to be executed at the data source. The data reader object is a stream based, forward only read the only retrieval of query results from the data source. Which do not update the data. Finally, the data adapter object, which populate a data set object which results from a data source. The data adapter object provides a bridge between the data set and the data source.
Advantages:
Ability to
cross: Communicate between heterogeneous environments.
ADO.NET has the exceptional benefit of establishing a connection between two heterogeneous environments. Once the connection is established ADO.NET could easily communicate between these two heterogenous environments.
Easily scalable: ADO.NET is highly
scalable, which means of requirement appear, it is flexible enough to be
expanded easily.
High in productivity:
ADO.NET is capable enough to build robust applications.
Performance:
There is no lacking or delay and it can set connections quickly to fetch data.
Applications communicate with a data base, firstly, to retrieve the data stored there and present it in a user-friendly way and secondly, to update the data base by inserting, modifying and deleting data.
Micro soft Active X data objects .net (ADO.NET) is a model, a part of the .NET frame work that is used by the .NET applications for retrieving, accessing and updating data.
Components
of database
Data table
collection
It contains all the tables retrieved
from the data source.
Data
Relation collection
It contains relationships and the links
between tables in a data set.
Extended
properties
It contains additional information like
the SQL statement for retrieving data, time of retrieval etc.
Data table
It represents a table in the data table
collection of data set. It consists of the data row and data column objects.
Data
relation: It represents a relationship in the data relationship collection of
the data set.
Data row
collection: It contains all the rows in the data table.
Data view:
It represents a fixed customized view of a
data table for sorting, filtering, searching editing and navigation
Primary key
It represents the column that uniquely
identifies a row in a data table.
Data row
It represents a row in the data table
Data column
collection
It represents all the columns in the
data table.
Data column
It consists of the number of columns
that comprise a data table.
ADO.NET
Connection String
Connection string is a normal string
representation which contains data base connection information to establish the
connection between data base and the application. The connection string
includes parameters such as the name of the driver, driver name and data base
name as well as security information such as user name, as well as security
information such as user name and password. Data providers use a connection
string containing a collection of parameters to establish the connection with
the data base.
You can connect your vb.net application
to data in a SQL server database using the micro soft .net frame work data
provider for SQL server. The first step in a vb.net application is to create an
instance of the server object and to establish its connection to an instance of
SQL server.
The SQL connection object is handling
the part of physical communication between the application and the SQL server
database. An instance of the SQL connection class in .NET framework is supported
the data provider for SQL server data base. When the connection is established
SQL Commands may be executed, with the help of the connection object, to
retrieve or manipulate data in the data base. Once the data base activities
over, connection should be closed and release the data base resources.
The close ()
method in SQL connection class is used to close the data base connection. The
close method roll back any pending transactions and releases the connection
from the SQL server database.
System.Data.sqlclient name space is the .net data provider for sql
server.
System.Data.oracleClient namespace is the .NET frame work data
provider for oracle.
System.Data.oledb
name space is the .net frame work data provider for OLE db.
System.Data.odbc name space is the .NET frame work data
provider for ODBC.
Connection:
connection object provide physical connection to the data source.
Command
object: perform SQL statement to be executed at the data source.
The Data
reader: sequentially read data
Data
adapter: bridge between the data set and the data source.
Data set:
disconnected set of records that are retrieved from the data base.
Rich text
box
The rich text box allows formatting the
text, it also provides the facility to save the text in the file. Drag and drop
rich text box control from the tool box on the window form
Allows entry and editing of text using
advanced formatting features such as paragraph formatting with left and right
indents, hanging indents, bold and italic font and so on. Also supports object
embedding using the OLE objects collection.
Rich text box does not have 64 k
character limit of ordinary text box controls, plus it also handles drag and
drop from both the clipboard and OLE with mouse button behaviour like micro
soft word
File name
[load from]: the filename of the .txt or .rtf
File
loaded into the rich text box
Enabled
: true or false, true means the
Object can respond to user
generated events
Mouse
pointer: The type of mouse pointer displayed
When over the rich
text box
Scroll
bars: No scroll bars, horizontal,
vertical or both
Font choose a font installed on this
system. It’s
Wise to choose standard windows
fonts such
as MS scans serif that are
universally available
size of font, bold, italic, underline
and strike out
Mouse
Icon: custom icon to use when the mouse
Pointer property is set to 99
Tool tip
text: sets the string to use as a tool tip for this
control. Dynamically
modified tool tips
WordWrap:If WordWrap
property is true, the text in the RichTextBox control automatically wraps to
the next line if required. If this property is set to true, horizontal
scroll bars are not displayed regardless of the Scroll Bars property setting.
FileRich text box methods
Find finds text within the control
Load
file loads a text file or existing
data stream into
the control
paste pastes the contents of the clipboard
into the
control
redo reapplies the last operation
Save
File saves the contents of the control
to a file
RTF control to demonstrate the following
word processor related functions
-
Opening
text, rtf
-
Saving
text
-
Implementation
of the page setup dialog control
-
Implementation
of print preview dialog control
-
Searching
text
-
Searching
for and replacing text
-
Adding
bullets to sections
-
Implementing
undo/redo within an RTB
Implementing select all, cut, copy and paste in rtf control.
-
Embedding
images
-
Setting
page and font colors
-
Implement
alignment options
We can
create a rich text box control using a
Form designer at design time or using the rich text box class
in code at run time.
Private sub Button1_click(Byval sender as System.object,
Byval e as eventargs) handles Button1.click
rt as new richtextbox()
rt.location = new point(20,20)
rt.width =300
rt..height =200
rt.backcolor = Color.Red
rt.forcolor = Color.Blue
rt.text = “I am dynamic rich text box”
rt.font = new font(“Georgia”,16)
end sub
ShortcutsEnabled property applies to the following
shortcut key combinations:
- CTRL+Z Click the Undo command
- CTRL+E Aligns the line or selected text to the centre of the
screen.
- CTRL+C Copy selected text
- CTRL+Y Redo the last action performed.
- CTRL+X Cut selected text.
- CTRL+BACKSPACE Deletes word to left of cursor.
- CTRL+V Paste.
- CTRL+DELETE Deletes word to right of cursor.
- CTRL+A Select all contents of
the page.
- CTRL+L Aligns
the line or selected text to the left of the screen.
- SHIFT+INSERT Paste.
Menus
The menu strip control represents the
container for the menu structure. The menu strip control works as the top level
container for the menu structure. The toolStripmenuItem class and the
ToolStripDropdown menu class provide the functionalities to create menu items,
sub menus and drop down menus.
The context menu strip control
represents a shortcut menu that popup over controls, usually when you right
click them. They appear in context of some specific controls, so are called
context menus. For example cut, copy or paste options properties.
The toolstripmenuitem class supports the
menus and menu items in a menu system. You handle these menu items through the
click events in a menu system.
-hide
and display menu items
-disable
and enable menu items
-add
access keys for menu items
-set
short cut keys for menu items
Hide
and display menu items
The visible property of the
toolstripmenuitem class allows you to
hide or show a menu item.
Private
sub Button1_click(sender as object, e as EventArgs) handles Button1.click
Projectoolstripmenuitem1.visible=false
End
sub
Disable
and enable new items
The Enabled property allows you to disable or gray out a menu item.
Private
sub Button1_click (sender as object, e as eventArgs) handles Button1.Click
projectToolstripmenuItem1.enabled
= false
end
sub
Access key
Set access keys for a menu allows a user
to select it from the keyboard by using the ALT key.
If you want to set an access key Alt + F
for the file menu, change its text with an added &(ampersand) preceding the
access key.
Short cut keys
When you set a short cut key for a menu
item, user can press the short cut from the keyboard and it would result in
occurrence of the click event of the menu
A short cut key is set for a menu item
using the short cut keys property, To set a short cut key Ctrl + E for the edit
menu
Menus are a
part of every good application and provide not only an easy way to navigate
within an application but also useful tools for working with that application.
Take, for example, visual studio.net, it provides menus for navigating the various
windows that it displays and useful tools for making the job of development
easier through menus and context menus (also called pop-up menus). For cutting,
copying and pasting code. It also provides menu items for searching through
code.
The main menu
control in vb.net provides several key features. First and foremost is that it provides
a quick and easy way to add menus, menu items and sub menu items in your
applications.
It also provides
a built-in editor that allows you to add edit and delete menu items.
An access key
(als0 known as an accelerator key) allows you to navigate the menu using the
Alt key and a letter that is underlined in the menu item. Once the access key
has been used the menu will appear to the screen and the user can navigate through
them using the arrow keys or the mouse.
Short cut keys
allow you to invoke the menu items without displaying the menus at all. For
example, you usually, use a control key and a letter such as ctr + x to cut
text.
Padding: how much space should appear between the content of
an element
Righttoleft no
Righttoleftautomirroring false
Automatic
mirroring takes place when the original language of the form has a left to
right
Shortcutkeys
none
Showshortcutkeys
true
Size 37,20
File handling
File class is
using for the file operations in vb.net. we can create, delete, copy, etc
operations do with a File class.
File.create(“c:\testfile.txt”)
Before we
creating a file object, we usually check that file exists or not. For that, we
are using the existing method in the File class.
File.Exists(“c:\testfile.txt”)
If we want the
copy of the file object, we can use the copy method in File class.
File.copy(“c:\textfile.txt”,
“d:\testFile.txt”)
When we want to
delete a file object we can use the delete methods in the file class
File.Delete(“c:\textfile.txt”)
A file is a
collection of data stored in a disk with a specific name and directory path.
When a file is opened for reading or writing, it becomes a stream.
I/O classes
The system.io
namespace has various classes that are used for performing various operations
with files, like creating and deleting files, reading from or writing to a
file, closing file, etc,
I/O class
Description
BinaryReader reads
primitive data
Binarywriter writes
primitive data
Directory helps in
manipulating a directory structure
Driveinfo provides
information for the drives
File
helps in manipulating files
StreamReader used for reading characters
StreamWriter is used
for writing characters
Imports system
Public class form1
Private sub Button1_click( byval sender as system.object,
Byval e as Eventargs) handles Button1.click
If file.exists (“c:\textfile.txt”) then
Msgbox(“file
‘textfile.txt’ exist”)
Else
File.create(“c:\testfile.txt”)
Msgbox(“file
‘textfile.txt’ created”)
End if
End sub
End class
The File Stream class represents a
File in the computer. File stream allow to move data to and from the stream as
arrays of bytes. We operate file using file mode in File Stream class.
Filemode.append : open and append to a file. If the file does
not exist, it creates a new file.
Filemode.Create: Create a new file, if the file exist it will
append to it.
Filemode.CreateNew: creates a new file. If the file exists,
it throws exception
FileMode.open: open
an existing file
Create a new
directory, we can call createDirectory from directory class.
Directory.CreateDirectory(“c:\testdir”)
Before we create
a directory, we usually check that directory exist pr not. For that we are
using the exists method in the directory class.
Directory.Exists (“c:\testdir”)
If we want to
move a directory and its contents from one location to another, we can use the
move method in the directory class.
Directory.Move(“c:\testdir”, “c:\changedir”)
When we want to
delete a directory, we can use the delete method in the directory class.
Directory.Delete
(“c:\testdir”)
IOException is
the base class for exception thrown while accessing information using streams,
files and directories. FileNotFoundException class is thrown the exception when
an attempt to access a file that does not exist on disk fails.
Imports system.io
Class form1
Private sub Button1_click(byval sender as System.object,
byval e as EventArgs) handles Button1.click
Try
File.copy(“c:\\tmp.txt”,”c:\\copytmp.txt”,true)
File.Delete (“c:\\copytmp.txt”)
Catch ex as System.IO.FileNotFoundException
Msgbox (ex.ToString())
End try
End sub
End class
File info
class
It
is providing properties and instance methods for the creation, copying,
deletion, moving and opening of files.
File info class is present int the I/O
package. Whenever we call the file info class method need to import namespace like
this
Imports
System.IO
Main properties of the class to get file
information like file extension, last access time, filename etc
Creation
time: creation time of the current file or directory
Extension: The extension part of the file
Isreadonly:
if the current file is read-only
Last access
time: time the current file or directory was last accessed.
Length: size
in bytes, of the current file
Name: name
of the file
File Stream
class
Exposes a stream around a file, supporting
both synchronous and asynchronous read and write operations.
Position :
set the current position of this stream
Read timeout:
set a value, in milliseconds, that determines how long the stream will attempt
to read before timing out.
Imports
System.IO
Module
Module1
Sub main()
Dim value As
String = File.ReadAllText("C:\file.txt")
Console.WriteLine(value.Length)
End Sub
End Module
In a sequential access file, you can write
data to the file on reading from it sequentially from the beginning of the file to
the end and vice versa.
Random access file: In some situations,
the programs require to access a particular record immediately. The records in
random access files can without searching through a large number of records as
in the case of a sequential access file. Random access file is used in instant
access system such as banking system, sales system, airline reservation system
Dialog
Box
There are many built-in dialog boxes to
be used in windows forms for various tasks like opening and saving files,
providing a page, providing choices for colors, fonts, page setup etc, to the
user of an application. These built-in dialog boxes reduce the developer’s time
and work load.
Abort
– when user clicks an abort button , to terminate
Retry
- Attempt
the operation again
Cancel - not save any of the changes made
Ignore – skip
The color dialog
control class represents a common dialog box that displays available colors
along with controls that enable the user to define custom colors. It lets the
user select a color.
Private sub button1_click (sender as object, e as EventArgs)
handles button1.click
Label1.forecolor = ColorDialog1.Color
End sub
Font Dialog Control
It prompts the
user to choose a font from among these installed on the local computer and lets
the user select the font, font size and color. It returns the Font and color
objects.
Private sub Button2_click ( sender as object, e as EventArgs)
handles button2.click
Richtextbox1.forecolor = FontDialog1.color
Richtextbox1.font = FontDialog1.Font
End sub
Open File Dialog
The open file dialog control
prompts the user to open a file and allows the user to select a file to open.
The user can check if the file exists and then open it.
properties Description
add extension The dialog
box automatically
adds a extension to a
file name if
the user omits the extension
Check File exists The dialog
box displays a
warning if the user specifies a file
name that does
not exists
private sub Button1_click (sender as object, e as EventArgs) handles
Button1.click
PictureBox1.image = Image.FromFile (OpenFileDialog1.Filename)
end sub
The OpenFileDialog component
displays a dialog box that allow the user to choose a file to open
The filename property can be
set prior to showing the dialog box, to initally display the given file name.
class Form1
private sub Button1_click (Byval sender as System.Object, Byval e as
System.EventArgs) handles Button1.click
dim dlg as new openfiledialog
dlg.showDialog()
dim filename as String
filename = dlg.FileName
msgbox(filename)
end sub
Normally when you want your user to open a file in your application, you
want to limit it to one or a couple of file types. For instance mostly opens
word file (with the extension .doc or .docx) and notepad mostly open text files
( with the extension .txt)
Save File Dialog
The save File Dialog control
prompts the user to select a location for saving a file and allows the user to
specify the name of the file to save data.
properties
Description
DefaultExt sets the default
file name extension
Overwriteprompt save as dialog box
displays a
warning if the user specifies a file
name
that already exists.
showhelp The help button is
displayed in the file
dialog box
title sets the file
dialog box title
method description
OpenFile opens the file with
read/write permission
private sub Button1_click ( sender as object, e as Eventargs) handles
button1.click
saveFiledialog.Filter =( "text files ",*.txt)
end sub
autoupgradeEnabled :automatically upgrade appearance and behavior, control
the behavior in certain events, assign hotkeys and shortcuts, add locations and
use advanced service functions.
Check path exists : if path or directory does exists.
create prompt : whether the dialog box prompts the user for permission to
create a file if the user specifies a file that does not exist.
fault Ext :The extension that is
used is determined by the Filter and DefaultExt properties
Dereferencelink : Whether the dialog box returns the location of the file
referenced by the shortcut
filter index : If you set the FilterIndex property, that filter will be
selected when the dialog box is displayed.
generate member: List of all
members, including inherited members.
initial directory: represents the
directory to be displayed when the open file dialog appears the first time.
SaveFileDialog.initialDirectory =@"d:\"
Windows forms
controls are reusable components that encapsulate user interface functionality
and are used in client-side windows applications. A button is a control which
is an interactive component that enables user to communicate with an
application which we click and release to perform some actions.
The button
control represents a standard button that reacts to a click event. A button can
be clicked by using the mouse Enter key or space bar if the button has focus.
Selects the form
on which the button control resides.
In the properties window, set the form’s button properties to
the button control’s name.
To respond to a button, click, in the button’s click event
handler write the code to run button1_click must be bound to the control.
Forecolor, text properties of the button control are changed.
Click event of the button is used to display a message.
When you want to
change display text of the button, you can change the text property of the
button.
Button1.text = “My first button”
Similarly, if you want to load an image to a button control,
you can code like this
Button1.image = Image.Fromfile(“ C:\mku.jpg”)
The following
vb.net source code shows how to change the button text property while form
loading event and to display a message box button pressing a button control.
Public class
form1
Private sub
form1_load(byval sender as System.object, byval e as Eventargs) handles
mybase.load
Button1.text=”click me”
End sub
Private sub button1_click(byval sender as System.object,
byval e as System.Eventargs) handles Button1.click
Msgbox(http:\\www.mkuniversity.ac.in”)
End sub
End class
A radio
button or option button is a type of GUI element that allows the user to choose
only one of the predefined set of options. When a user clicks on a radio
button, it becomes checked, and all other radio button with same group becomes
unchecked.
The radio button
and the check box are used for different functions. Use a radio button when you
want the user to choose only one option.
The radio button
control is used to provide a set of mutually exclusive options. The user can
select one radio button in a group.
Methods
Perform click
It is used to fire click event of
radio button control
It is used to show radio button
control
It is used to set cursor or focus
on a radio button control.
Public class form1
Private sub radiobutton_checkedchanged
(byval sender as system.object, Byval e as system.EventArgs) handles
radiobutton1.checkedchanged, radiobutton2.checkedchanged,
radiobutton3.checkedchanged
If
radionbutton1.checked = true then
Msgbox(“BCA”)
Elseif radiobutton2.checked = true then
Msgbox (“B.Sc CS”)
Else
Msgbox(“B.Sc IT”)
End if
End sub
End class
Picture box control
Picture box
control is used to display images in bitmap, Gif, icon or jpeg formats.
You can set the
image property to the image you want to display, either at design time or at
run time. You can programmatically change the image displayed in a picture box.
Picturebox1.image
= image.fromfile(“c:\mku.jpg”)
The size mode
property, which is set to values in the picture box size made enumeration,
controls the clipping and positioning of the image in the display area.
Picturebox1.sizemode=picturebox.sizemode.stretchimage
There are five different picture box size mode available to
picture box control.
Auto size –
sizes the picture box to the image
Center image
- centers the Image in the picture box
Normal –
places the upper left corner of the image at
Upper left in the picture
box.
Stretch
image – allows you to stretch the image in code
You can change the size of the display
area at runtime with the client size property.
Picturebox1.clientsize
= new size (x-size, y-size)
let us put a picture box and a button control on
the form. We set the image property of the picture box to mku.jpg. The Click
event of the button named Button1 is coded to stretch the image to a specified
size
Timer Control
Timer control
plays an important role in the client side programming and server side
programming, also used in windows services. By using this timer control,
windows allow you to control when actions take place without the interaction of
another thread.
We can use timer
control in many situations in our development environment. If you want to run
some code after a certain interval of time continuously, you can use the timer,
as well as to start a process at a fixed time schedule, to increase or decrease
the speed in an animation graphics with time schedule etc
With the timer
control, we can control programs in milli second, seconds, minutes and even in
hours. The timer control allows to set interval property in milliseconds ( 1
second is equal to 1000 milli seconds). For example, if we want to set an
interval of two minute we set the value at interval property as 1 00 000, means
120 x 1000 .
Public class
form1
Private sub timer1_click( byval sender as System.object,
byval e as System.EventArgs) handles timer1.tick
Lablel1.text = DateTime.Now.Tostring
End sub
End class
Start and stop
timer control we can control the timer control object that when it starts its
function as well as when it stops its function. The timer control has a start
and stop methods to perform these actions.
Timer1.start() -
timer starts functioning
Timer1.stop() -
timer stops functioning
Timer properties
Interval: gets or sets the interval at which to raise the
elapsed event
Enabled: gets or sets a value indicating whether the timer
should raise the elapsed event.
Name: A unique
identifier for the control. This property is required and defaults to the name
of the control.
The Modifiers
property is the
access modifier assigned to that member variable.
List box control
Vb.net
provides several mechanisms for gathering input in a program. List box control
displays a list of choices which the user can select from.
You can use
the add or insert method to add items to a list box. The add method adds new
items at the end of an unsorted list box. The insert method allows you to
specify where to insert the item you are adding.
Listbox1.items.add(
“Sunday”)
If you want to
retrieve a single selected item to a variable, you can code like this
Dim var as
String
var
=listbox1.selectedItem
If you change
the selection mode property to multiple select, then you will retrieve a
collection of items from listbox1.selecteditems property.
Listbox1.selectionmode
= selectionmode.multisingle
Private sub Button1_click (Byvalsender as System.object, Byva
e as Eventargs) handles Button1.clivk
Listbox1.items.add(“Chennai”)
Listbox1.items.add(“bangalore”)
Listbox1.items.add(“hydrabad”)
Listbox1.items.add(“Trivandrum”)
End sub
S. Mugesh
ReplyDelete