Limited Time Offer: Get 2 Months of ABCmouse.com for only $5!

Programming III

June 19, 2012 (TUESDAY)

ASSIGNMENT #1

1. What is .NET Framework?

2. ASP .Net

3. ADO .Net


CHAPTER 1                          INTRODUCTION TO VB.NET

 

The .NET FRAMEWORK is a software framework developed by Microsoft that runs primarily on Microsoft Windows. It includes a large library and provides language interoperability (each languages can use code written in other languages) across several programming.

ASP.NET is a web application framework developed and marketed by Microsoft to allow programmers to build dynamic Web sites, Web applications and Web services. (dynamic web page – one page can alter its appearance & contents depending on the input conditions.

ADO.NET (ActiveX Data Objects for .Net) is a set of computer software components that programmers can use to access data and data services. It is a part of the base that is included with the Microsoft .Net Framework.

VISUAL BASIC .NET

  • Is a multi-purpose computer programming language from Microsoft that is suitable for most development needs, It also provides base class libraries (BCL) provided by the .Net Framework.
  • An integrated development environment (IDE), also known as Integrated Design Environment and Integrated Debugging Environment, is a type of computer software that assists computer programmers to develop software. In the case of Visual Basic .Net, that IDE is Visual Studio.

VISUAL STUDIO IDE – The Visual Studio consists of several sections or tools that the developer uses while programming. As you view the IDE for a new project you generally have three sections in view:

  • The Toolbox on the left
  • The Solution Explorer on the right
  • The Code/Design View in the middle

TOOLBOX – The toolbox is a palette of developer objects or controls that are placed on forms or web pages, and then code is added to allow the user to interact with them.

SOLUTION EXPLORER – This is a section that is used to view and modify the contents of the project. A Visual Studio Windows Application Project will generally have a form object with a code page, references to System components and possibly other modules with special code that is used bybn the application.

CODE/DESIGN VIEW – This is where the magic takes place. Forms are designed graphically; it is also where developers write the code that makes everything in the application work.

PROPERTIES WINDOWS – shows all the control properties to be changed at design time.

VISUAL STUDIO .NET START-UP SCREEN

 

PURPOSE OF WINDOWS in the IDE

WINDOW

PURPOSE

CLASS VIEW

Display the classes, methods and properties included in a solution

SOLUTION EXPLORER

Display the names of projects and files included in a solution

START PAGE

Create and Open projects, Access Visual Studio .Net information online, customize various program settings in the IDE.

TOOLBOX WINDOW

Displays item that you can use when creating a project.

 


LESSON 2:                            VARIABLES

 

VARIABLE – it is a computer memory location where users can temporarily store data.

 

For example:

Think of it like this: a VARIABLE is an empty cardboard box. Now, imagine you have a large room, and in this room you have a whole lot of empty cardboard boxes. Each empty cardboard box is a single variable. To add two numbers together, write the first number on a piece of paper and put the piece of paper into an empty box. Write the second number on a piece of paper and put this second piece of paper in a different cardboard box.

Now all of your thousands of empty cardboard boxes two of them contain pieces of paper with numbers on them. To help you remember which of the thousands of boxes hold your numbers, put a sticky label on each of the two boxes. Write “number1” on the first sticky label, and “number2” on the second label.

 

Setting up variables:

Dim number1 As Integer

Dim number2 As Integer

 

number1 = 3

number2 = 5

 

Here’s the breakdown of the variable declaration:

 

DIM

  • Short for Dimension. It is a type of variable. You declare (tell Visual Basic) that you are setting up a variable with this word. Just remember to start your variable declarations with DIM.

Number1

  • This is a variable. Our storage area. After the DIM word, VB is looking for the name of your variable. Its good practice to give your variables a name appropriate to what is going on in a variable.

As Integer

  • We’re telling visual basic that the variable is going to be a number (integer)

=

  • Equals sign is not actually an equal sign. The equal = sign means assign a value of.

 

 

 

 

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

 

End Sub

 

PRIVATE

  • Private means that no other part of the program can see this code except for our button.

BUTTON

  • Short for Sub routine. The “Sub” word tells VB that some code follows, and that it needs to be executed.

_CLICK

  • This is something called an event. In other words, when the button is clicked. The Click event will fire, and the code we’re going to write will be executed.

END SUB

  • This signifies the end of our code.

 

Selecting a Name to a variable

  1. The name must begin with a letter.
  2. The name must contain only letters, numbers and the underscore character. No punctuation characters or spaces are allowed in the name.
  3. The name cannot contain more than 16383 characters. (Thirty two characters is the recommended maximum number of characters to use.
  4. The name cannot be a reserved word, such as Print.

 

SUMMARY

Objects – things with attributes and behavior

Behavior – are actions that an object performs

IDE – used to manage windows, set properties and write code for an application.

Forms – are user interface of an application

  • Contains controls such as button and label
  • Have code to perform specific task

& - join two strings together. This is what you called CONCATENATION.

EXERCISES:

This application adds two numbers by declaring variables and Msgbox.

Public Class Form1

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

   End Sub

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

        Dim number1,  number2, answer As Integer

        number1 = 3

        number2 = 5

        answer = number1 + number2

        MsgBox(answer)

    End Sub

End Class

 

This application Concatenates Two Strings of a given variable and Output the strings in a textbox.

Public Class Form1

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

    End Sub

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnAdd.Click

        Dim FirstName ,  SurName, FullName As String

        FirstName = "Raquel"

        SurName = "Salazar"

        FullName = FirstName & " " & SurName

        TextBox1.Text = FullName

    End Sub

End Class

 

This application requires the user to type his/her First Name and Last Name and output the said text in a Message box.\

Public Class frmName

    Private Sub frmName_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

    End Sub

    Private Sub btnConcatenate_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnConcatenate.Click

        Dim FirstName, Surname, FullName As String

        FirstName = txtFirstName.Text

        Surname = txtSurName.Text

        FullName = FirstName & " " & Surname

        MsgBox(FullName)

    End Sub

End Class

 

This application requires the user to type his/her First Name and Last Name and output the said text in the textbox.

Public Class frmName

    Private Sub frmName_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

    End Sub

    Private Sub btnConcatenate_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnConcatenate.Click

        Dim FirstName, Surname, FullName As String

        FirstName = txtFirstName.Text

        Surname = txtSurName.Text

        FullName = FirstName & " " & Surname

        txtFullName.Text = FullName

    End Sub

End Class


July 19, 2012

Assignment: (SHORT COUPON BOND)

PART 1- IF STATEMENTS

Start a new Project. Add a textbox, a label and a button to your new form. Then write a program that does the following:

  1. Asks users to enter a number between 10 and 20
  2. The number will be entered into the textbox.
  3. When the button is clicked, Your Visual Basic Code will check the number entered the textbox.
  4. If it is between 10 and 20, then a message will be displayed.
  5. The message box will display the number from the textbox.
  6. If the number entered is not between 10 and 20 then the user will be invited to try again. And whatever was entered in the textbox will be erased.

 

PART 2- SELECT CASE STATEMENTS

Add a combo box and another button to your form. Create a list of items in your combo box. The list of items in your combo box can be anything you like- pop groups, football teams, favorite foods, anything of your choice. Then try the following:

Use a select case statement test what a user has chosen from your dropdown list. Give the user a suitable message when the button was clicked. (minimum of 10 choices)

Get 2 Months for $5!