Sie sind auf Seite 1von 20

San Carlos de Guatemala University

Engineering
Science and Systems Engineering
Technical English I

How to use a programming language with visual basic

Name: Myriam Priscila Velasquez


Cumes
ID No. 201216037

INDEX
Introduction
Objectives
Chapter 1

What is visual Basic?

Chapter 2

Common elements of Visual Basic


environment and how to start

Chapter 3
Chapter 4

Properties window
Helpful tips

Chapter 5

Lets use the programming language

Chapter 6

How to change variables into text

Chapter 7

Lets add a button to a form.

Chapter 8

Basic elements on a code:

Chapter 9

Example

Chapter 10

Some Issues could appear while


working with visual basic
Conclusions
Anexes

Introduction

Over the past years technology has been increasing its presence in
many aspects of life: Jobs, Hobbies, Trips, etc. And technology has
needed and used some other resources to be created. Some of those
resources have been programming languages. They are some kind of
vocabulary and grammatical rules for instructing a computer to perform
tasks needed by the programmer.
This mini-handbook shows us how to easy can be to create a project. It is
also for the users to be familiarized with programming languages,
because even when every programming language has its own syntaxes,
rules, keywords all they use need to be developed in a similar way. In this
case, the IDE (Integrated Development Environment) will be of Visual
Basic. You will be able to learn specific things you need to know those
kinds of languages, about how fascinating they are and the most
important thing: How start programming.
You will find a short description of the tools and options Visual Basic
offers and some tips to take into consideration in order to start. This is for
beginners but you can be an expert once you start programming you will
be willing to continue and learn more and more.

Objectives

To make programming language understandable.

To make Visual Basic usage accessible for everyone.

To let people know that it order to program, its not mandatory to


have experience. Just the necessary tools.

To empower people with some knowledge in order to start with a


project.

To give just essential topics of how to work with Visual Basic in


order to not fluster people with too much information.

To encourage beginners with some useful tips about how to deal


with a programming language.

To warn people about important rules to follow in order to not make


a mess with too many instructions which are part of a program.

What is Visual Basic?


Its name refers to the method used to create what users can see;
visual. And it refers to the friendly interface; basic. Visual Basic was
initially a procedural programming language. Then, Microsoft decided to
make Visual Basic into more powerful object oriented programming
language.
It is one of the most interactive programming languages and that is why
it one of the most used in the world for every kind of programmers.
Essentially, a Visual Basic user interface consists of objects that can be
placed on the screen and can be arranged so that the screen looks
pretty for the customer or user.

Every program created in Visual Basic has some kind of structure: The
modules are like chapter, the procedures are like paragraphs and the
lines are la phrases. But there is nothing to worry about. In a few steps
you will be able to speak the Visual Basics language.

Common elements of Visual Basic environment

Forms (also known as windows)

Buttons (such as command buttons and radio buttons)

Boxes (such as text boxes and check boxes)

Labels

Pictures (such as icons and graphics)

How to start

To design your user interface, follow these steps:

1. Create a form

2.
Choose the object you want to draw from the Toolbox.

3. Draw the object on the form.

Exam

Properties window for a form

ple

To change the form's title to any name, simple click


in the box on the right of the Text property and type
in the new name.
Properties can be set by highlighting the items in
the right column then change them by typing what
we need. There are several option of the form such
as font, location, size, foreground color, background
color, MaximizeBox, MinimizeBox and more.
And this is not the only way it can be changed. A
form can also be modified by codes. And that is one
of the hundred of options that a programming
language can give us. That makes BV a multiprogramming modes making it easy.
It is also important to mention that visual basic
works so similar to any software of Windows. The
buttons, the variety of options for every task and
the different commands which can be used to
perform and action. For example: The tool bars at
the top of the window give us options as save a
document, open a new file, run a program, to edit
something, to view a code, etc.

Helpful tips
On the form the controls can be added and aligned

The FormLayout icon lets choose the way the application is


going to be opened when pressing play.
And there are some other Windows to edit the programming
code like Code Editor and there are some others to see the variables
while the programm is being executed like Debbuger, Immediate,
Locals and Watch. And these tools and windows are the IDE
(Integrated Development Environment).
Something useful is to choose on Environment the Promp to Save
Changes option and the click on When a Program Starts in order for
the changes to be saved before clicking to reproduce.
Help button: It has the ability of giving you information about any
property or form by just selecting it and clicking F1.

Lets use the programming language


Now that we already know something about the Visual Basic
environment lets focus on how to create a program.
It is important to remember the use of variables. They can take any
value, as letters (string), whole numbers (integer), fractions (double) or
true and false values (boolean).

*To assign a value to a variable the equal sign is used (=).


Whenever the commands start to being entered an editor will open a
part of the program called Form1_Load which is also known as a
procedure. And the code which will be written on that procedure is going
to be the group of instructions that are going to be performed when the
form will charge for the first time.
*Every time a code needs to show a real text it needs to be entered
between quotation marks .
MsgBox is used to show something.

How to change variables into text:


Each variable from Visual Basic can be changed into text using the CStr
abbreviation. It comes from Convert to String. In the same way as CStr
can be used there are some abbreviations to do that as:

Example:
1.
Dim A As Integer = 1
Dim B As Integer = 2
MsgBox(CDbl(A / B)

In this example the value showed will be:


0.5

*Dim: Dimension Its the variable used to declare (or "tell" Visual Basic)
that you are setting up a variable under that name.

2. txtResult.Text = Val(txtOper1.Text) * Val(txtOper2.Text)


This example is showing how the command Val will show the result of
two text variables in a whole number.
To play a form you just need to click Debug > Start from the menu bar. Or
press F5.

To stop it:
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

When clicking the right button of the


mouse with the form previously
selected. The option to save the
project will appear.

Lets add a button to a form.

Click on the Button tool in the toolbox with the left hand mouse
button once.
Place the mouse to a blank area of the form - It will turn into a
cross
Press and hold the left mouse button.
With the button drag across the form and you can stop holding it
once you are happy with the size.

This method can be used to draw most of the controls. And once a
control is created it can be modify with the options of the properties
window.
In order to start working with a code it is just necessary to double click
on the control.

Basic elements on a code:


Private: It means that no part of the program can see the code within
that part of the code except for the control that you would be working
with.
Sub: It refers to Subroutine. The "Sub" word tells that some code
follows, and that it needs to be executed
Name of the control we are working with.
Event: Instructions, what the code is going to do when executed.
End Sub: The subroutine ends right here. This signifies the end of our
code.

Example:
This is a program to find the highest digit of three numbers entered in
different boxes.

Private Sub Cmdborrar_Click()


Txtnum1.Text = ""
Txtnum2.Text = ""
Txtnum3.Text = ""
End Sub
Private Sub cmdhallar_Click()
Dim A, B, C
A = Txtnum1.Text
B = Txtnum2.Text
C = Txtnum3.Text

If (A > B) Then
If (A > C) Then
MsgBox ("The highest number
is: " & A)
Else
MsgBox ("The highest number
is: " & C)
End If
Else
If (B > C) Then

MsgBox ("The highest number


is: " & B)
Else
MsgBox ("The highest number
is: " & C)
End If

End If
End Sub
Private Sub Command1_Click()
Guia_1_1.Hide
Guia_1.Show
End Sub

And this is the way it may looks like:

Some Issues could appear while working with visual basic:

Versioning problems associated with runtime.

Poor support

Inability to create multi-threaded applications.

Variant types have a greater performance and storage overhead


than strongly typed programming languages.

The development environment is no longer supported by Microsoft.

But they are something you can deal with and take advantage of this
Software.
Just remember that the most important thing while creating a code is
working clean, with certain names related with the part of the program
that is being defined. In order to dont have misunderstandings while
making bigger projects.

Now you can feel free to work with Visual Basic with this information. Go
ahead and give yourself the freedom to do what you want by using the
lots of options and tools available that Visual Basic offers.

Conclusions

Visual Basic is for everyone willing to start using


programming language.
There are different ways to perform actions and get the same
result.
It does not matter the way a program is developed it just has
to follow the rules for the programming language used.
Visual Basic helps users to make everything understandable.
Visual Basic makes the visual part or a program easier.
Anyone can start with simple projects in order to learn about
how to program.
It is necessary sometimes to learn by hearth some topics like
in every new language.
It is important to be organized in order to get a successful
program without errors.

Glossary

1. Boolean:
Computers of or relating to a data type having two possible values
representing true or false.

2. Caption:
a title or explanation for a picture or illustration, especially in amag
azine.
3. Command
4. To direct with specific authority or prerogative; order
5. Currency:
Something that is used as a medium of exchange; money.
6. Debug: to detect and remove errors from (a computer program).
7. Drag:
to draw with force, effort, or difficulty; pull heavily or slowly along;
haul; trail:
8. Fore color: Fore:
Situated at or toward the front, as compared with something else.
Fore color: Color situated in the front.
9. Layout: An arrangement or plan
10.
Multi-threaded: Interwoven or ornamented with threads.
11.
String:
any series of things arranged or connected in a line or following clo
sely one after another.

Annexes
Annex 1: Tools in the Visual Basic Toolbox

Ico

Tool Name

What This Tool Does

n
Pointer

Selects objects

Picture box

Draws a box to display graphics

Label

Draws a box to display text

Text box

Draws a box that can display text and let


the user type in text

Frame

Groups two or more objects together

Command
button

Draws a command button

Check box

Draws a check box

Option (or radio)


button

Draws a radio button

Combo box

Draws a combo box

List box

Draws a list box

Horizontal scroll
bar

Draws a horizontal scroll bar

Vertical scroll
bar

Draws a vertical scroll bar

Timer

Places a timer on a form

Drive list box

Draws a drive list box that displays all the


disk drives available

Directory list box

Draws a directory list box that displays a


directory on a particular disk drive

File list box

Draws a file list box that displays files in a


specific directory

Shape

Draws a geometric shape such as a circle


or a square

Line

Draws a line

Image box

Draws a box to display graphics

Data control

Draws a control to link a program to a


database file

OLE

Draws a box to insert an OLE object

Annex 2: Abbreviations

Annex 3: Types of variables

Bibliography
http://mat21.etsii.upm.es/ayudainf/aprendainf/Visualbasic6/vbasic60.pdf

https://www.youtube.com/watch?v=7lpuICNVP4

http://www.vbtutor.net/vb2008book/vb2008me_preview.pdf

http://www.dummies.com/how-to/content/meeting-the-tools-in-the-visual-basictoolbox.html

https://msdn.microsoft.com/library/xk24xdbe%28v=vs.90%29.aspx

http://pemrograman-ilmiyah.blogspot.com/2011/02/visual-basic-60-session-2.html

http://www.homeandlearn.co.uk/NET/nets1p11.html

http://visualbasicmavd.blogspot.com/