Parag’s Den

Dedicated to my adored friends…..

Archive for the ‘– VB.Net’ Category

01- Introduction to VB.NET

Posted by paragdongre on June 4, 2008

What is VB.NET

Visual Basic .NET is Microsoft’s Visual Basic on their .NET framework. Visual Basic is an object oriented programming language. Any programmer can develop applications quickly with Visual Basic. It is a very user-friendly language. All you have to do is arrange components using visual tools and then write code for the components. Most programmers of Visual Basic use Visual Studio for their development needs. Moving forward, Microsoft’s .NET framework is composed of preprogrammed code that users can access anytime. This preprogrammed code is referred to as the class library. The programs in the class library can be combined or modified in order to suit the needs of programmers. Programs in .NET run on the CLR or the Common Language Runtime environment. Regardless of computer, as long as this environment is present, programs developed in a .NET language will run.

Evolution of VB.NET

Before VB .NET, there was VB and before there was VB, there was BASIC. BASIC stands for Beginner’s All-purpose Symbolic Instruction Code. It was developed in 1963 by computer scientists John Kemeny and Thomas Kurtz in Dartmouth College. It was a general purpose programming language that was intended for beginners. In 1975, when the MITS Altair 8800 Microcomputer was released, BASIC became Altair BASIC, developed by the computer heavyweights Bill Gates and Paul Allen. During the eighties, when the personal computer was starting to get into everyone’s homes, the BASIC computer language started to lose its hold on the market because more and more people and corporations were using computer programs for complex tasks rather than simple and “basic” tasks. In 1991, BASIC was infused with its Visual component and became Visual Basic. The new graphical user interface was pioneered by Alan Cooper. Visual Basic was not an instant hit at first due to compatibility issues but it began getting a solid following in the mid to late nineties when developers started becoming familiar with it. In the new millennium, the Visual Basic .NET became the successor of the Visual Basic programming languages.

Pros and Cons

Pros

  1. You can develop programs faster using the VB .NET programming language. You have so many resources in the .NET Class Library to take advantage of. VB .NET has full access to the .NET framework.
  2. It is easier to program using Microsoft development environments like Visual Studio.
  3. It is easier to organize your thoughts in an object-oriented programming language like VB .NET.
  4. There are a lot of books and tutorials to improve your skills in VB .NET.
  5. The VB language itself interfaces with Microsoft applications seamlessly (VBA).

Cons

  1. Debugging is very difficult on the VB .NET programming languages especially with long codes.
  2. You’ll spend hundreds of dollars purchasing development tools from Microsoft (Retail version of Visual Studio costs around $300).

Where is VB.NET Most Useful

The VB .NET programming language is most useful for rapid application development or RAD. If you want to get your programs up and running in a jiffy then you should use VB .NET. Since VB .NET is more suitable for quick and easy programming, it is not recommended for the large, enterprise-wide software development solutions. Debugging and finding your way through long and tangling lines of VB .NET code will simply give you headaches.

Getting Your Copy of VB.Net

Now that you understand what VB .NET is all about,you should get a copy of the programming language as soon as you can. You can either get a copy of Visual Basic at your local retailer or download a freeware version at the Microsoft website. If you want to get started right away, copy the following hyperlink to your browser’s address bar to download your freeware copy of Microsoft Visual Basic 2005 Express Edition – http://msdn.microsoft.com/vstudio/express/vb/you have to be patient because the file is quite large. If you have the time and the resources then you should get the latest versions of Visual Studio or Visual Basic. Once you have your own copy of Visual Basic, you will be on your way to learning one of the most powerful programming languages to date. Good luck in learning the VB .NET programming language!

 

Posted in - VB.Net | 1 Comment »

02- Microsoft Frameworks

Posted by paragdongre on June 4, 2008

.Net Framework

What is the Microsoft .NET framework?

You may be wondering why the .NET aspect of Visual Basic is so important in today’s times. In simple terms, .NET is a framework made by Microsoft so that developers can take advantage of code on the internet. Many developers through the years have developed code for their specific programming languages like C#, C++, Visual Basic, etcetera… Instead of making code over and over again, the .NET framework allows programmers and developers to use code on the .NET framework to aid in the development of their software programs. Imagine the .NET framework as sort of a file sharing program that benefits all the programmers across all the programming languages that use the .NET framework. When you program in Visual Basic .NET, you are taking advantage of a rich source of programming code that has been accumulated through the years.

What are the advantages of using the Microsoft .NET framework?

  • Code execution and deployment is made much simpler for developers.
  • Code execution and deployment is assured to be safe and free from viruses.
  • Programming models are now similar across different languages. Choosing a programming language is already up to you.
  • Programming models adhere consistently with object oriented styles.

Object Oriented Programming

Object oriented programming is a programming paradigm that makes use of objects to develop computer programs. When you objectify certain parts in a program or when you modularize it, you promote greater flexibility in overall programming. When you use object oriented programming languages, you can make objects interact with one another to accomplish goals. Instead of writing code one by one every time you make a program, you can use the previously designed objects to your advantage. The VB .NET language is one of the premiere object oriented programming languages in the market today.

In object oriented programming, objects interact with one another to produce the desired results from the programmer. This makes programming easier, less tedious, and more efficient.

Classes, Inheritance and Methods

Classes

Classes are used to describe objects. They are the overarching description of an object. For example, cat is a class that is used to describe an actual cat. If you have an actual cat named Garfield then it is an object. In the object oriented programming paradigm, it is important that you understand the difference between a class and an object. As you go on doing programming tasks, you need to understand these concepts in order to make your programming easier and much more effective.

Inheritance

Some classes will have subclasses. For example, if you mention the class cat then there can be a subclass lion, tiger, or cheetah. Subclasses are said to inherit the traits of its mother class. In the VB .NET programming language, objects inherit the properties of its mother objects.

Methods

Now that you are familiar with the essence of objects in object oriented programming, you should now familiarize yourself with what objects can do. The ability of an object to do something or perform a task is said to be its method or methods. If the object Garfield is of class dog and subclass house cat then it may have methods such as eating and meowing. An object in the VB .NET programming language may have one or more methods that you can take advantage of while developing your applications.

You will eventually learn how to use the several tools at your disposal in the later chapters. Once you are familiar with the core concepts of the VB .NET programming language, it will be easier for you to take advantage of the limitless possibilities before you. You will be using a lot of objects later on so make sure that you know what they are.

Microsoft SQL

Microsoft SQL stands for Microsoft Structured Query Language. The Microsoft SQL Server program uses the relational database management system. Microsoft SQL allows you to manipulate databases. Databases are basically repositories for data. If you want to store the grades of all the students in a university then you certainly need to have a database system around. Microsoft SQL also stores a lot of code that is available through the .NET platform. Stored procedures and several functions are made available for the programmer so that they could develop competitive applications quickly and efficiently. You will learn how to take advantage of the .NET codes available and the use of databases in the later chapters.

http://www.microsoft.com, Microsoft SQL Server is one of the premiere database management systems in the market today.

Getting your copy of Microsoft SQL

Now that you are familiar with the frameworks that are essential to run the VB .NET programming language, you may have to download them unless they are already installed on your computer. You can get a free copy of Microsoft SQL and the .NET framework at http://msdn.microsoft.com/vstudio/express/sql/download/. On the installation screen, you will be notified if there are already .NET frameworks installed on your computer. If there are no previously installed .NET programs then you may have to download the said files.

 

 

 

 

Posted in - VB.Net | Leave a Comment »

03- Forms

Posted by paragdongre on June 4, 2008

User Form and Toolbox

The User Form

The first thing that you should familiarize yourself with in the Visual Basic .NET programming language is the user form. The user form is the box where you can add all sorts of features. On older versions of Visual Basic, the user form has dots on it. The user form acts as a basic interactive tool between the programmer which is you and the one who will use the program.

 

 

You can add so many features and objects on your user form. These things are more commonly referred to as controls. Controls are such things like textboxes, comboboxes, option buttons, etcetera… You will learn more about certain controls in this chapter and the later chapters.

The Toolbox

Your Visual Basic program is equipped with a toolbox. You can access your toolbox anytime and manipulate your forms, controls, modules, etcetera… Simply click on a control and add it to your user form so that your user can access it when your program is run.

 

The controls that are going to be discussed in this chapter are the most basic. They are the label, the textbox, and the command button.

 

Just click on the corresponding buttons on your Toolbox to access the controls. Shown above are the respective buttons.

Labels, Textbox, Properties

The Label

The label is the way you put text on your user form. If you want your user to know what certain things are for then you have to use the label. Click on the label button and put a label on your user form.

The Textbox

The textbox is the way the user puts text on the user form. If you want an input in the form of text, number, or symbol, then you should simply put a textbox in your user form. Try putting a textbox on your user form now.

The Command Button

The command button is a control on the user form that is used to prompt action. Action can come in the form of running a code, closing an application, or simply clearing input made by a user. Click on the command button control on the toolbox and place one on your user form.

Properties

Every object that you have in your program will have properties. You can modify the properties of any object on the properties box. It is normally located in the lower right corner of your screen. You can modify attributes like the alignment, style, and labels. Modify the text that will appear on the first label that you created.

 

 

 

Posted in - VB.Net | Leave a Comment »

04- Basics of Programming

Posted by paragdongre on June 4, 2008

 

Variables

Variables are basically elements in a computer program that can take any assigned value. They can change from time to time, depending on the programmer and the user. For example, if a computer program requires a user to enter his or her name then the entity “name” will change from time to time depending on the user. The element “name” is considered a variable and can take on any value assigned to it. You will be using a lot of variables in your programming.

Data Types

Any kind of variable or element can take on a data type. There are several data types in Visual Basic. To name the most popular and the most useful are the following.

  1. String – this data type is made up of empty text, a single letter or several letters, or a group of words.
  2. Boolean – this data type is either True or False, or 1 or 0 representing the former and the latter, respectively.
  3. Byte – this data type can take on values from 0 to 255
  4. Integer – this data type can take on whole number values from -32,768 to 32,767
  5. Long – this data type can take on whole number values from -2,147,483,648 to 2,147,483,647
  6. Single – this data type can take on floating point numbers or numbers with decimals from -3.402823E38 to – 1.401298E(-45) and from 1.401298E(-45) to 3.402823E38
  7. Double – this data type can take on floating point numbers or numbers with decimals from – 1.79769313486231E308 to – 4.94065645841247E(–324) and from 4.94065645841247E(–324) to 1.79769313486231E308
  8. Variant – this data type can take on any kind of value. Use this data type sparingly because it takes up more than twice the memory of the other data types.

Declaring Variables

If you are ready to declare a variable in a program then you should use the following code:

 Dim X As Integer

Once a variable is declared in a program, you or the user can utilize it appropriately.

Memory Allocation for the Variables

Variables that have more complex data types take up more memory on the computer. Using too much memory can slow down a program or in some cases, may cause a computer to hang. Use your variables wisely and declare them appropriately. For example, if you have a variable that states the number of points of a basketball player in a game then it would be wise to declare “player_points” as byte instead of integer. No basketball player in history has scored more than 255 points in a single game and there is no such thing as a negative basketball point.

 

Operators

Operators are the basic way of manipulating data. The following operators are the most common operators that you will use in programming.

The “+” operator is used if you want to add elements together.

The “-” operator is used if you want to subtract one element from the other. The “-” operator is also used as a negative sign for negative values.

The “*” operator is used for multiplying elements.

The “/” operator is used if you want to divide an element with another element.

The “=” sign denotes that the values on the left side of the “=” sign are equal to the values on the right side.

A basic equation in a program may look like the code below.

 3 + x = 4<
 MsgBox (x) 

If this program is run, a message box will appear on the screen indicating the correct value of x, which is 1.

Writing and Running the Code

Interacting with the User

The intermediary between you, the programmer, and the users out there is the user form. You have learned how to put the textbox and the command button in the previous chapter. This time, you are going to use it. Make a user form with basic textboxes, labels, and a command button similar to the one below.

 

Writing the Code

Simply double click any element on your user form to begin writing code. To start off, double click “Button1” and see a code screen come up. When you type in the code for your program on this screen, make sure that you are referring to the right elements and variables all the time. You do not want to end up jumbling your data. If you are referring to data in Textbox1 then make sure that you don’t have the data of Textbox3 in mind. Once you get all things organized, your code may look like the one below.

Public Class Form1
 private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)  Handles Button1.Click

 TextBox3.Text = Val(TextBox1.Text) + Val(TextBox2.Text)

 End Sub
End Class

 

Visual Basic is very user friendly. As you can see, simply double clicking a feature on your user form will automatically insert code. In the code above, take note that the “Val()” code is used to differentiate text from numerical value. Try removing the Val() code and see what happens to the result. You will learn little tidbits of coding as you go along this tutorial so pay attention and absorb all this knowledge.

Running the Program

Once you have the code in place, press F5 or the “play” button on the task bar. You will enter “debug” mode. Test your program and see if it works. If you want to exit debug mode, simply press the “X” button on the upper right corner of the user form or the “stop” button on the task bar.

 

Posted in - VB.Net | Leave a Comment »

05- Strings

Posted by paragdongre on June 4, 2008

 

Text Variables

String variables are an entirely different form of variables. As you may have noticed, all the other variables that were mentioned in the previous chapter have something to do with numbers. String variables deal with text. When you deal with text variables, the commands and the methods associated with them are entirely different. For example, when was the last time that you have heard someone multiply letters? What is the result when you multiply the letter “k” with the letter “n” ? When you work with text variables or string variables, make sure that you do not confuse the numerical manipulation commands with the string or textual manipulation commands.

Declaring the Text Variable or the String Variable

Simply type in the code below to declare a string variable in your program.

 

Dim Jordan as String

 

OR

 

Dim [name of variable] as String

 

Blanks

Sometimes you will encounter blanks with text variables. For example, if a user enters the name ” Jordan” instead of “Jordan,” there will be a space or a blank in front of it. If you want to rid the blanks at the start and at the end of text entered by the user then you can use the trim method. Simply use the code as illustrated below to trim any string variables.

 
        Dim Name As String
 
        Name = Trim(TextBox1.Text)
 
        MsgBox (Name)
               

As you can see, simply enter the text in the Trim() function and the spaces at the start and at the end of the text variable will be gone.

Note: Sometimes users will forget to put an entry in a textbox if you ask them to. In order to recognize blanks, simply use “”. Note that ” ” is different from “” because the former has a space bar entry while the latter has nothing in it. Visual Basic .NET recognizes the difference between the two.

String Position

With VB .NET, you can locate a string within a string. The command used to identify a string within a string is the InStr() command. See the code below and see how it works.

 
        Dim Result As Integer
 
        Result = InStr("Display", "p")
 
        MsgBox(Result)
 

The result returns a value of 4 because “p” is the fourth occurrence on the string. Try changing “p” to “isp” and see what happens. The general structure of the InStr() command is shown below.

 
Instr("[string to look at]","[string to be look for]")

 

Equal Command with Text

If you want text to be represented within a variable then you can use the equals command. See the code below and learn how the equals command is used.

 
        Dim Represent As String
 
        Represent = "This is the result."
 
        MsgBox(Represent)
               

The main structure when using the equals command is as follows.

 
[variable] = "[text]"
 

The variable will then obtain the value of the text.

Working with Text

Joining Text

Aside from using the “=” sign from numerical values, you can also use the “+” sign too. The “+” sign is used to join text together or to concatenate them. If you want to join text together, simply use the “+” sign as seen below.

 
Dim Result As String
 
Result = "Sun" + "day"
 
MsgBox(Result)
               

The result in the message box is the word “Sunday”. Try joining different kinds of texts together. The basic structure for joining text is as follows.

 [first string] + [second string] 

Replacing Text

If you want to replace a certain string or substring then you can use the Replace() command. See the code below and learn how it is used.

 
Dim Represent As String
 
Represent = "Display".Replace("Display", "Screen")
 
MsgBox(Represent)
 

The entire word “Display” is replaced with the word “Screen”. Try changing Replace(“Display”, “Screen”) with Replace(“ispl”,””) and see what happens. The general structure of the Replace command is as follows.

"[string to be looked at]".Replace("[string to be replaced]","[string to replace it]")
 

Inserting Text

If you wish to insert a string of text into an existing string then you can use the Insert() command. See the code below and learn how it is used.

 
        Dim Represent As String
 
        Represent = "Day".Insert(1, "ispl")
 
        MsgBox(Represent)
 

The result that is displayed in the message box is “Display”. Note that the first character in the String is “D” and that is why the “ispl” string was inserted after the character “D”. Try changing Insert(1, “ispl”) to Insert(2, “ispl”) and see what happens. The general structure of the Insert command is as follows.

“[string to be looked at]”.Insert([nth character where string will be inserted], “[string to be inserted]”)

Posted in - VB.Net | Leave a Comment »

06- Conditionl Logic

Posted by paragdongre on June 4, 2008

Conditional Operators

Operators that describe or state a relationship on one side of an expression with the other side of an expression is called a relational or conditional operator. The “=” sign is an operator that states that the values on the left side of the expression is equal to the right side of the expression, thus making it an equation. There are many other conditional operators that you can use in Visual Basic. They are the following.

  • The “<” sign is used to describe an expression where the left side is “less than” the right side.
  • The “>” sign is used to describe an expression where the left side is “greater than” the right side.
  • The “<=” sign is used to describe an expression where the left side is “less than OR equal to” the right side.
  • The “>=” sign is used to describe an expression where the left side is “greater than OR equal to” the right side.
  • The “<>” sign is used to describe an expression where the left side is “not equal to” the right side.

 

Combining Conditional Operators

You can combine the use of conditional operators using the following commands.

The “AND” command combines two conditional operators together. See the code below for an example.

 If x > 5 and y < 3 then z = x – y

The “OR” command selects which one of the two conditional operators are satisfied or dissatisfied. See the code below for an example.

 If x < 5 or y > 6 then z = x + y

 

If – Then

The If-Then statement is used to execute commands given that a set of conditions are satisfied. The basic structure of an If-Then statement is like the one below.

If x < 4 then
 x = x + 1
End If

OR

If [condition] then 
 [command lines]
End If

You can also put additional commands if a condition does NOT hold. You can use the “Else” command to do this. An example of how this is used is shown below.

If x < 4 then
 z = x + 3
Else
 z = x + 9
End If

OR

If [condition] then
 [command lines]
Else
 [command lines]
End If

 

Select Case

The Select Case statements are similar to the If-Then statements. The Select Case statements are used for executing different command lines in several different circumstances. For example, you can run a specific set of commands in scenario one, a specific set of commands in scenario two, and another set of commands in scenario three. Look at the code below and see how the Select Case logic works.

Sub ()

        Dim x As Integer

        Dim result As String

 

        x = 0

        result = “no value”

 

        Select Case x

            Case Is < 0

                result = “x is a negative integer”

            Case Is = 0

                result = “x is neither a positive nor a negative integer”

            Case Is > 0

                result = “x is a positive integer”

        End Select

 

        MsgBox(result)

              

End Sub

In the code above, you can see that the value for x can have three possible outcomes in the message box. Try changing the values of x to -4 and then to 9.

The basic structure of a Select Case code is as follows

        
        Select Case [variable]
               Case [1]
                       [command lines]
               Case [2]
                       [command lines]
               .
               .
               .
               Case [N]
                       [command lines]
        End Select

 

Conditional Logic and User Form

Make a new user form and arrange it as seen below.

You can toggle the starting user form of your application by selecting “My Project” on the Solution Explorer window and then choose “Startup form.”

Double click the button in the middle of your new user form and then write code that will identify if x is a positive, a negative, or neither a positive nor a negative integer. Hint: Review the code awhile ago and infuse it to the user form.

The code for identifying if x is a positive or a negative integer may look similar to the code below.

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

        Dim x As Integer
        Dim result As String

        x = TextBox1.Text

        Select Case x
            Case Is < 0
                result = “Negative”
            Case Is = 0
                result = “Neither”
            Case Is > 0
                result = “Positive”
        End Select

        TextBox2.Text = result

  End Sub

 

Posted in - VB.Net | Leave a Comment »

07- Loops

Posted by paragdongre on June 4, 2008

For Loop

Loops

Count the number of cups you need to fill a pitcher. This number is feasible and may be programmed on a computer as seen below.

 
        cups = 0
        ‘pitcher is now empty.’
        cups = cups + 1
        cups = cups + 1
        cups = cups + .5
        ‘pitcher is now full.’
        msgbox(cups)

In the code above, you will notice that you can actually count the cups one by one. You will know when the pitcher is empty and you will know when the pitcher is full. In some cases, counting things one by one isn’t actually practical anymore. For instance, what if you were asked to count the number of cups needed to fill a swimming pool? Does this sound fun to you? If you are really bored and have nothing to do with your life then you might as well count the number of cups one by one. If you are knowledgeable with loops then you can let the computer do the counting.

For

The For Loop is called the For Loop because it loops “for every number.” In the code below, you will see that the For Loop adds “for every number.”

        
        counter = 0
        sum = 0
        for counter = 1 to 50
          sum = sum + counter
        next counter
        msgbox(sum)

If you loop the code in your head, it would go like 1 + 2 + 3 + 4 + … … + 49 + 50 = sum. “For every” number, the sum is incremented.

The For Loop takes on the structure below.

        
        For [variable] = [1 to N]
         [command lines]
        next [variable]

 

Do Loops

Do

The Do Loop is called the Do Loop because it “does commands” under certain conditions. There are two types of the Do Loop.

Do While

The Do While Loop does commands while a certain condition holds. See the code below for an example of the Do While Loop

 
 Do while x < 100
  x = x + 1
 Loop
 Msgbox (x)

You can also put the While condition after the Loop command. See the code below for an example.

        
 Do
  x = x + 1
 Loop While x < 100
 Msgbox (x)

If the while is put at the Do line then it will check the condition before it executes the commands. If the while is put at the Loop line then it will execute the commands first before checking the condition. The program will loop based on the conditions given.

The Do While Loop takes on the basic structures below.

        
 Do While [condition}
  [command lines]
 Loop

OR

        
 Do
  [command lines]
 Loop While [condition]

Do Until

The Do Until Loop is called a Do Until Loop because it runs commands until a certain condition is satisfied. Check out the code below for an example.

        
 Do until x = 7
  x = x + 1
 Loop
 Msgbox (x)

Like the Do While Loop, you can also put the until command on the Loop line just like the code below.

        
 Do
  x = x + 2
 Loop Until x = 12
 Msgbox (x)

If the Until is put on the Do line then the computer will check the condition before it performs the commands while if the Until is put on the Loop line then the computer will execute the commands first before checking the conditions.

The Do Until Loop takes on the structures below.

        
 Do Until [condition]
  [command lines]
 Loop

OR

        
 Do
  [command lines]
 Loop Until [condition]

 

Loops and User Forms

Awhile ago, a question was posed if it was possible to count the number of cups to fill a swimming pool. Now that you are equipped with the knowledge of loops, try making a program that can calculate the number of cups needed to fill a swimming pool.

 

You can make a program that can calculate this number without using loops but use loops now for exercise purposes. You will benefit from this later on.

Your code may look something like the one below.

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

 

 ‘one liter is equivalent to .001 cubic meters OR m^3        

‘one cup is equivalent to approximately 230 milliliters OR .00023 m^3         

 

Dim Depth As Double        

Dim Length As Double        

Dim Width As Double         

Depth = TextBox1.Text        

Length = TextBox2.Text       

 Width = TextBox3.Text         

Dim Volume As Double         

Volume = Depth * Length * Width         

Dim Cups As Double        

Dim Counter As Double          

Counter = 0        

Cups = 0         

Do Until Counter > Volume           

  Cups = Cups + 1            

Counter = Counter + 0.00023         

Loop         

Counter = Counter – 0.00023        

Cups = Cups + (Volume – Counter) / 0.00023         

TextBox4.Text = Cups     

End Sub 

Posted in - VB.Net | Leave a Comment »

08- Forms(Advanced)

Posted by paragdongre on June 4, 2008

Learn more tools available in User Form

There are several tools at your disposal on the Visual Basic Toolbox. Listed below are some of the most basic tools aside from the already mentioned label, textbox, and button.
Check out the toolbox and feel free to modify any of your user forms.
Checkbox
Enables the user to select or clear the associated component.
Checked Listbox
Displays a list of items with a check box on the left of each item.
Combobox
Displays an editable textbox with a drop down list of permissible values.
DateTimePicker
Enables the user to pick a date and time and to display the date and time in a specified format.
LinkLabel
Displays a label control that supports the hyperlink capability.
Listbox
Displays a list where the user can select items.
Listview
Displays a list of items in one of five different views.
Masked Textbox
Uses a mask to distinguish between proper and improper user input.
Month Calendar
Displays a monthly calendar wherein the user can select a date.
Notify Icon
Displays an icon in the notification area, on the right side of the windows taskbar.
Numeric Up Down
Specifies support for transacted initialization.
Picture Box
Displays a picture.
Progress Bar
Displays the progress of an operation to a user.
Radio Button
Enables the user to select one option among other radio buttons.
Rich Textbox
Provides the user with advanced text entry.
Tool Tip
Displays information when the user moves the pointer over a control.
Tree View
Displays a hierarchical view of labeled items to the user.
Web Browser
Enables the user to browse the web through a user form.
Aside from the aforementioned tools, feel free to use the other more advanced tools on your toolbox.

Posted in - VB.Net | Leave a Comment »

09- Database

Posted by paragdongre on June 4, 2008

Download a Sample Database from the Microsoft Site

Start this chapter by downloading a sample Database from the Microsoft Site. Enter this URL on your address bar and begin downloading. http://www.microsoft.com/downloads/details.aspx?familyid=C6661372-8DBE-422B-8676-C632D66C529C&displaylang=en . Make sure that you remember where you put the file because you will be specifying the directory later on. Save any previous work you have done on the Visual Basic Application and then create a new project.

Adding a Data Source

The first step in connecting to a database is by identifying the source. Go to the Data Sources tab on the upper right side of the Visual Basic screen and then Add a New Data Source.

 

Select “Database” and then “New Connection…”

Select Data Source and then set it to “Microsoft Access Database File…”

 

The database file name is “Nwind.mdb”. You should know where you saved this *.mdb file when you downloaded it earlier.

Click OK and proceed with adding the data source.

Once you are done, you will see the database for Northwind traders as shown below.

Posted in - VB.Net | Leave a Comment »

10 – Assignments

Posted by paragdongre on June 4, 2008

You have learned many things throughout this tutorial. Now is the time for you to put your skills to the test. This chapter will give you a sample application and several problems to work on. The first problem has a sample application answer while the remaining problems are for you to solve yourself. Remember that there are several ways to solve a problem. Do not worry if your application is not the same as the sample application. As long as it works properly, you are good to go. Good luck!

Make a Calculator that converts Celsius to Fahrenheit and vice versa

Sample User Form is shown below

 

Sample Code is shown below

 

Public Class Form1

    Dim C As Single
    Dim F As Single

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

        C = TextBox1.Text

        F = (9 / 5) * C + 32

        TextBox2.Text = F

    End Sub

    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click

        F = TextBox1.Text

        C = (5 / 9) * (F – 32)

        TextBox2.Text = C

    End Sub

End Class

Posted in - VB.Net | Leave a Comment »