Structure OF Programming Languages
Structure OF Programming Languages
Structure OF Programming Languages
OF
PROGRAMMING
LANGUAGES
VISUAL BASIC
.NET
CONTENTS:
1. What is Visual Basic .NET?
DEVELOPER : MICROSOFT
The textbox gets added to the top left position of your form. To
move it down, hold your mouse over the textbox and drag to a
new position:
Notice the small squares around the textbox.
These are sizing handles. Move your mouse over
one of them. The mouse pointer turns into an
extended line with arrowheads. Hold your left
mouse button down and drag outwards. The
textbox is resized. Play around with the sizing
handles until you're happy with the size of your
textbox.
Click on the label to select it. Now hold your left mouse
button down on the label. Keep it held down and drag it
to the left of the textbox.
Create two more labels, and position
them to the left of the textboxes. You
should now have a form like this one:
To see what your Form looks like as a
programme, click Debug > Start from
the menu bar. Or press F5 on your
keyboard:
To stop the programme from running, you can
do one of the following:
1. Click the Red X at the top right of your Form
2. Click Debug > Stop Debugging from the
menu bar
3. Press Shift + F5 on your keyboard
You can also click the Stop button
on the VB toolbars at the top, as in
the image below:
SAMPLE PROGRAM FOR VISUAL BASIC .NET
(VB .NET)
Public Class Form1
Inherits System.Windows.Forms.Form
[Windows Form Designer generated code]
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
MessageBox.Show("Hello World!")
End Sub
End Class
OUTPUT;
‘ HELLO WORLD ‘
Press F5 or go to the Debug menu and select Start to start the program.
You should see an alert box that says "Hello World!" and then the main
window (with nothing on it) should open. Click the "X" in the title bar like
you would to quit any program!
VISUAL BASIC .NET
CONTROLS
Visible Controls
Textboxes
A TextBox is used to get and display text. A TextBox can only
display text in one font, so it can't be used for word processing.
By default, a TextBox will only display text on a single line. If you
require more than one line you can set it's Multiline property to
true.
•Passwords
If you need a TextBox for accepting a password you should set it's PasswordChar
property to a character. The character you choose will be displayed in the
TextBox instead of what is actually typed. Good characters to choose include *
and ●.
•Clipboard
You can copy the selected text to the clipboard by using the TextBox.Copy
method. Use the TextBox.Paste method to paste text into the Textbox from the
Labels
Labels are used to display text. Unlike the textbox, it is not
meant to accept input from the user. Often a Label is used to
describe another control, and is often used as a prompt for a
Textbox.label display read-only text as far as the user is
concerned.
Buttons
Buttons are controls that are usually raised that the user most
often can click on to perform some action defined by the
programmer. Once the programmer has added the button
control to a form, he can define an event handler to perform an
action when the button is clicked.
Checkboxes
A check box indicates a two-way choice or state (true/false)
which can be edited by the user. Check boxes are shown on the
screen as a square box that can contain white space (for false)
or a check mark (for true). Adjacent to the check box is normally
shown a caption describing the meaning of the check box.
Inverting the state of a check box is done by clicking the mouse
Radio Buttons
A radio button allows the user to choose exactly one of a
predefined set of options. Radio buttons are arranged in groups
of two or more and displayed on screen a list of circular holes
that can contain white space (for unselected) or a dot (for
selected). Each radio button can show a caption describing the
choice that this radio button represents. This is done by setting
the radio button's text property.
RichTextBox
Can easily save Richtext files with Colours and Fonts. Has all the
qualities of a textbox but with built in save
method(richtextbox1.savefile(pathname)) and
openfile(Richtextbox1.openfile(filename)).
Other controls not visible at
design time
OpenFileDialog
An OpenFileDialog displays the standard "Open" dialog. It lets the
user browse for a file.
SaveFileDialog
A SaveFileDialog displays the standard "Save" dialog. It lets the user
browse for a directory to save files and enter a filename. It can
(optionally) automatically append extensions to the filename.
FontDialog
A FontDialog lets the user to select a font from a list of installed
fonts.
ColorDialog
A ColorDialog lets the user select predefined color or specify a
custom color.
Timer Control
A Timer Control is a control that will execute code at intervals. It is
not visible at runtime. The interval can be set in the properties in the
measurement of milliseconds. The timer control will continue to
Comparative Samples
The following simple example demonstrates similarity in syntax
between VB and VB.NET. Both examples pop up a message box
saying "Hello, World" with an OK button.
•Circle, Line
§Currency
§MsgBox
§String
Keyword, Function or Statement
•Type
•String Functions
Variant
Disposition
New Keywords, Functions, and Statements in VB
.NET
Class
§IsArray
§Short, CShort
§MyClass
Class
§Namespace
§DirectCast
§IsReference
Disposition
END OF PRESENTATION
BY: aLjoN