0% found this document useful (0 votes)
48 views29 pages

Visual Basic: by Leo Karlo Primero

Visual Basic is a programming language and integrated development environment (IDE) that is used to build window-based applications and web applications. Some key points about Visual Basic: - It was founded in 1987 by Microsoft and became popular with version 2.0. The latest version is Visual Basic 2010. - It is a graphical user interface (GUI) programming language that allows creating graphics, tools, and objects for user interaction. - It uses an object-oriented programming (OOP) model where objects make up the application. Classes describe how objects function and interact. - Coding in Visual Basic involves understanding classes and objects, assigning variables, performing calculations, converting variable types, and using conditional statements like

Uploaded by

nimmy
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
48 views29 pages

Visual Basic: by Leo Karlo Primero

Visual Basic is a programming language and integrated development environment (IDE) that is used to build window-based applications and web applications. Some key points about Visual Basic: - It was founded in 1987 by Microsoft and became popular with version 2.0. The latest version is Visual Basic 2010. - It is a graphical user interface (GUI) programming language that allows creating graphics, tools, and objects for user interaction. - It uses an object-oriented programming (OOP) model where objects make up the application. Classes describe how objects function and interact. - Coding in Visual Basic involves understanding classes and objects, assigning variables, performing calculations, converting variable types, and using conditional statements like

Uploaded by

nimmy
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
You are on page 1/ 29

Visual Basic

By Leo Karlo Primero


What is Visual
Understanding Basic?
its foundation
• De facto standard
• Founded in 1987 by MSDN
• Competition with other languages
• Version 2.0 made it popular
• Went up to 6 until it was called BASIC.NET
• Newest version is Visual Basic 2010

4/18/2010 2
Visual Basic is What?
• A GUI
– Graphics, tools, objects
• An OOP – “*Object Oriented Programming”
– Objects make the application.

4/18/2010 *Italics - Taken from Starting out with 3


Visual Basic 2008 page 7
Visual Basic is a GUI
LOL it’s
It is A GUI – Graphic User Screen shot of Visual Basic’s Integrated
Development Environment
Interface
•Can create graphics for
interaction
•Between User and application
•Interaction:
•Text boxes, radio buttons, and
more

4/18/2010 4
Visual Basic is Object Oriented
Objects to play around with Screen shot of VB tool box
• It all begins with a web
form…
– Then place in any object unto
it
• A radio button, a text box, a
progress bar, and anything…
• They make application
construction look so easy
• Visual Basic makes
programming faster

4/18/2010 5
Don’t take my word for it…

Dan Mabbut, a BASIC language expert, said that

“*excellent programs could be written faster and


cheaper with Visual Basic than with any of
those languages (C, C+ and Java).”

*Italics - Taken from


4/18/2010 http://visualbasic.about.com/od/applicatio 6
ns/a/whatisvb.htm
How do you code in Visual Basic?
This code is an example
First of a class
Private Sub Form1_Load(ByVal sender As
• Understand that each System.Object, ByVal e As
object has a class System.EventArgs) Handles
MyBase.Load
• Look to your right cboDistributorNo.Items.Add(100)
cboDistributorNo.Items.Add(101)
cboModelNo.Items.Add("puri-clear")
cboModelNo.Items.Add("Envirn_Safe")
cboDistributorNo.SelectedIndex = 0
cboModelNo.SelectedIndex = 0
End Sub

4/18/2010 7
What is a class?
• A class is a contemporary of an object Private Sub Form1_Load(ByVal sender As
System.Object, ByVal e As
• It makes up the object System.EventArgs) Handles
– Underneath it are its codes MyBase.Load
• Divided into subroutines cboDistributorNo.Items.Add(100)
cboDistributorNo.Items.Add(101)
• Describes how the process
cboModelNo.Items.Add("puri-clear")
work
• Main class is always at the top of the cboModelNo.Items.Add("Envirn_Safe
code ")
• What this codes does is to place the cboDistributorNo.SelectedIndex = 0
numbers into the cboModelNo.SelectedIndex = 0
cboDistributorNo.Items End Sub
• This can also be an option statement
(rules of processing)
• You are going to see its output

4/18/2010 8
Before and After…
BEFORE… AFTER…

4/18/2010 9
A class and its codes
is like a teacher and its students
A teacher instructs his student
Class and codes on what to do
• A class cannot function Poor guy…
without its codes
• A class name will appear first
– But no functions
• It is an empty classroom with
no activity
• The teacher is bored (no brain
activity)
• A class needs codes to be
active!
– It will be bored like the teacher.

4/18/2010 10
Codes within classes are instances!
• Instances are…
– Data, string, procedures, events, calculations and
etc.
– They help make class work

4/18/2010 11
Coding part 1 – Naming conventions
*“The first three letters of the name should be a
lowercase prefix indicating the control’s type.“

Be serious about naming conventions…

• No one wants a combo box to be called


combName
• Preferably called cboDistributorNo.
– It speaks to us…
• “I am a cbo Distributor No. a combo box that distributes
numbers…”
*Italics - Taken from Starting out with
4/18/2010 12
Visual Basic 2008 page 14
Prefixes help
• Visual Basic detects prefixes
• Here is why

4/18/2010 13
Known prefix list
• lbl = Label
• txt = Text Box
• cbo = Combo Box
• btn = Button

4/18/2010 14
To give an object a name
• Go to Properties
Window
• Find Name
• Type in value

4/18/2010 15
Coding Part 2 – Assigning a Variable
• A variable is an instance
• You must dim it first
– Ex:
Public Class frmTuitionCalc
Dim ResidenceStatus As Integer
– Then follow it up with an As statement

4/18/2010 16
CodingHow
Partto2Give
– Assigning
it a valuea Variable

• To assign a value is simple…


– Ex:
ResidenceStatus = 0

• You can do the same with a string


– Ex:
lblDateString.Text = txtDayOfWeek.Text & ", " _
*What this does is that lblDateString.Text will have the same text as
txtDayofWeek.Text

• If you see a “.” assume it connects to a property

4/18/2010 17
lblDateString.Text = txtDayOfWeek.Text & ", " _
.Text is text property that will
affect the highlighted area
• Here is the output of it to
show you what I am talking
about
• Look

4/18/2010 18
What happened was
• At the last slide
lblDateString.Text gathered all the textual data of
the other variables and placed them in one string.

4/18/2010 19
Coding Part 3: Performing calculations
• Operators: • Examples
– + is addition Integer = 5 + 5;
– - is subtraction Integer = 5 MOD 5;
– *MOD gets remainder (remainder shows)
– / is *floating point Integer = 5 / 5;
division
– \ is *Integer division
– *^ is exponentiation

*Italics -Taken from Starting out with Visual


4/18/2010 20
Basic 2008 page 122
Coding Part 4: Converting between
variable types
Conversion Example
• Convert between items *Dim anInteger As Integer = 54
• Use a Ctype function MsgBox (CStr(anInteger))
This will convert anInteger = 54
to output as a string “54”

*Italics -Taken from


http://msdn.microsoft.com/en-
4/18/2010 us/library/8bzk8e8c%28v=VS.90%29.aspx 21
Coding Part 5: If…Then and
If…Else…Then Statements
Both statements are conditional
statements Example
• Visual Basic is unique on Private Sub chkRush_Click(ByVal
sender As Object, ByVal e As
this System.EventArgs) Handles
chkRush.Click
• If… Then is one condition is If chkRush.Checked Then
met rbtUPS.Enabled = True
rbtSpecialCarrier.Enabled = True
• If… Else… Then is if one Else
condition is not met then rbtUPS.Enabled = False
another event will trigger rbtSpecialCarrier.Enabled = False
End If
End Sub

4/18/2010 22
Here is how it works
Before After

The code implies that if chkRush.Checked = True(Rush Order is checked)


then rbtUPS (UPS radio button) and rbtSpecialCarrier (Special Carrier radio
button) will be enabled (made usable)

4/18/2010 23
Coding Part 6: The Case Statement
Another condition statement Example
• There can be several Private Sub rbtInternational_Click(ByVal sender As
Object, ByVal e As System.EventArgs) Handles
options rbtInternational.Click
ResidenceStatus = 2
• However a condition must End Sub
be met for one of them to Case Is >= 12
Select Case ResidenceStatus
work Case 0
Tuition = 1500
Case 1
Tuition = 2300
Case 2
Tuition = 3200
End Select
*NOTE: This is a shortened version of the actual code

4/18/2010 24
How it works
The code’s decision Here it is
• User inputs hours taken
• Then tuition will output
base on a case
• Typed-in 12 hours and
checked International
– International is Case 2
• Outputs $3,200

4/18/2010 25
My view on Visual Basic
• I find it faster to finish applications but it takes time to learn.
• The community is quite active
– There are people helping each other online
• I find it to be very reliable
• A programmer can decide how to tighten his application’s security
– I have a template that has a log-in feature
• MSDN is still maintaining it with bug fixes and updates
– As long as the user downloads them
• When anyone needs help with Visual Basic he can ask help from MSDN
• Visual Basic has its own Online Help
• Visual Basic’s history has shown me that MSDN still updates it and even changes
VB’s external and internal structures.
• Visual Basic’s unique features made it an all-around programming language
– Besides Programmers coded VB’s codes to create advanced applications
• One major downside is that it does not focus on actual programming
– People may not be programmers to use Visual Basic

4/18/2010 26
Outcome for Visual Basic
• So far for what I see Visual Basic is persistent
and may last for a very long time.
• I believe that after it fixes up its problems
Visual Basic will still have a lot of customers
that are willing to quickly make applications.

4/18/2010 27
Works Cited
Gaddis, Tony, and Kip Irvine. Starting out with Visual Basic 2008.
Fourth. Boston: Pearson Education, Inc., 2008. 7. Print.
Gaddis, Tony, and Kip Irvine. Starting out with Visual Basic 2008.
Fourth. Boston: Pearson Education, Inc., 2008. 14. Print.
Gaddis, Tony, and Kip Irvine. Starting out with Visual Basic 2008.
Fourth. Boston: Pearson Education, Inc., 2008. 122. Print.
n.p., "Closer Look: Converting from One Variable Type to Another."
MSDN.Microsoft.com. MSDN, n.d. Web. 18 Apr 2010.
<http://msdn.microsoft.com/en-
us/library/8bzk8e8c%28v=VS.90%29.aspx>
Mabbut, Dan. "What is Visual Basic?." VisualBasic.About.com.
About.com, n.d.. Web. 18 Apr 2010.
<http://visualbasic.about.com/od/applications/a/whatisvb.htm>.

4/18/2010 28
FIN
GOD DESERVES THIS GLORY

I am thankful that He helped me persevere


through this.
Praise Jesus

4/18/2010 29

You might also like