Visual Basic By Leo Karlo Primero What is

Visual Basic By Leo Karlo Primero

What is Visual Basic? Understanding 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 Visual Basic 2008 page 7 3

Visual Basic is a LOL it’s a GUI It is A GUI – Graphic User Interface • Can create graphics for interaction Screen shot of Visual Basic’s Integrated Development Environment • 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). ” 4/18/2010 *Italics - Taken from http: //visualbasic. about. com/od/applicatio ns/a/whatisvb. htm 6

How do you code in Visual Basic? First • Understand that each object has a class • Look to your right 4/18/2010 This code is an example of a class Private Sub Form 1_Load(By. Val sender As System. Object, By. Val e As System. Event. Args) Handles My. Base. Load cbo. Distributor. No. Items. Add(100) cbo. Distributor. No. Items. Add(101) cbo. Model. No. Items. Add("puri-clear") cbo. Model. No. Items. Add("Envirn_Safe") cbo. Distributor. No. Selected. Index = 0 cbo. Model. No. Selected. Index = 0 End Sub 7

What is a class? • • • A class is a contemporary of an object It makes up the object – Underneath it are its codes • Divided into subroutines • Describes how the process work Main class is always at the top of the code What this codes does is to place the numbers into the cbo. Distributor. No. Items This can also be an option statement (rules of processing) You are going to see its output 4/18/2010 Private Sub Form 1_Load(By. Val sender As System. Object, By. Val e As System. Event. Args) Handles My. Base. Load cbo. Distributor. No. Items. Add(100) cbo. Distributor. No. Items. Add(101) cbo. Model. No. Items. Add("puri-clear") cbo. Model. No. Items. Add("Envirn_Saf e") cbo. Distributor. No. Selected. Index = 0 cbo. Model. No. Selected. Index = 0 End Sub 8

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

A class and its codes is like a teacher and its students Class and codes A teacher instructs his student on what to do Poor guy… • A class cannot function 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 comb. Name • Preferably called cbo. Distributor. No. – It speaks to us… • “I am a cbo Distributor No. a combo box that distributes numbers…” 4/18/2010 *Italics - Taken from Starting out with Visual Basic 2008 page 14 12

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 frm. Tuition. Calc Dim Residence. Status As Integer – Then follow it up with an As statement 4/18/2010 16

How to Give it a value Coding Part 2 – Assigning a Variable • To assign a value is simple… – Ex: Residence. Status = 0 • You can do the same with a string – Ex: lbl. Date. String. Text = txt. Day. Of. Week. Text & ", " _ *What this does is that lbl. Date. String. Text will have the same text as txt. Dayof. Week. Text • If you see a “. ” assume it connects to a property 4/18/2010 17

lbl. Date. String. Text = txt. Day. Of. Week. 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 lbl. Date. String. 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 - is subtraction *MOD gets remainder / is *floating point division – is *Integer division – *^ is exponentiation – – 4/18/2010 Integer = 5 + 5; Integer = 5 MOD 5; (remainder shows) Integer = 5 / 5; *Italics -Taken from Starting out with Visual Basic 2008 page 122 20

Coding Part 4: Converting between variable types Conversion Example • Convert between items • Use a Ctype function *Dim an. Integer As Integer = 54 Msg. Box (CStr(an. Integer)) This will convert an. Integer = 54 to output as a string “ 54” 4/18/2010 *Italics -Taken from http: //msdn. microsoft. com/enus/library/8 bzk 8 e 8 c%28 v=VS. 90%29. aspx 21

Coding Part 5: If…Then and If…Else…Then Statements Both statements are conditional statements • Visual Basic is unique on this • If… Then is one condition is met • If… Else… Then is if one condition is not met then another event will trigger 4/18/2010 Example Private Sub chk. Rush_Click(By. Val sender As Object, By. Val e As System. Event. Args) Handles chk. Rush. Click If chk. Rush. Checked Then rbt. UPS. Enabled = True rbt. Special. Carrier. Enabled = True Else rbt. UPS. Enabled = False rbt. Special. Carrier. Enabled = False End If End Sub 22

Here is how it works Before After The code implies that if chk. Rush. Checked = True(Rush Order is checked) then rbt. UPS (UPS radio button) and rbt. Special. Carrier (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 options • However a condition must be met for one of them to work Private Sub rbt. International_Click(By. Val sender As Object, By. Val e As System. Event. Args) Handles rbt. International. Click Residence. Status = 2 End Sub Case Is >= 12 Select Case Residence. Status 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/enus/library/8 bzk 8 e 8 c%28 v=VS. 90%29. aspx> Mabbut, Dan. "What is Visual Basic? . " Visual. Basic. 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
- Slides: 29