Launch Microsoft Visual Studio and create a new VB.Net windows forms project. Visual Studio places a new form in the design window.
Click the "View" button, and then click "Toolbox" to open the Toolbox.
Find the "Button" control inside the Toolbox, and double-click it to add a button named "Button1" to the form.
Locate the "PictureBox" control inside the Toolbox. Double-click that control to add it to the form. Visual Studio names it "PictureBox1." PictureBox controls display images.
Scroll through the Toolbox and find the "Textbox" control. Double-click that control to add it to the form. Its name will be "TextBox1."
Re-arrange the three controls on the form so that they do not overlap. To move a control, click it, and drag the control to a new location on the form.
Move to the Solution Explorer window and right-click the project file. A drop-down menu appears. Click "Properties" to display the Properties window.
Locate the "Resources" tab on the left side of the window. Click that tab to display the Resource Designer panel. This panel allows you to add and remove resources from a project.
Click the "Add Resource" button. A drop-down menu displays the types of resources you can create and add. Click "Add New Text File," and then type a name for the text file you wish to add.
Click "Add." Visual Studio adds a new text file resource to the project and displays it in the "Resources" folder in the Solution Explorer.
Click the "Add Resource" button again in the Resources panel to display the drop-down menu. Click "Add Existing File." Windows Explorer opens and displays your hard drive's files and folders.
You can add any type of file as a .resx resource by clicking the "Add Resource" button, and then clicking "Add Existing Resource." The menu in the "Add Resource" menu also contains options named "Add New Icon" and "Add New Image."
Click "Add Resource," and then click "Add New String." A table with multiple columns appears. Enter "String1" in the "Name" column, and type anything you like in the "Value" column.
Click the "Form1" tab at the top of the Visual Studio interface. The form with your three controls appears.
Add the following code before the method's "End Sub" statement:
PictureBox1.Image = My.Resources.xyz
Replace "xyz" with name of the image file you added to the resources. This statement assigns that image resource to the PictureBox control.
Add this code below the code shown in the previous step:
TextBox1.Text = My.Resources.String1
This statement locates the resource named "String1" and assigns its value to the "TextBox1" text box. Using string resources this way allows you to save text data in any string resource and retrieve it later when a user reruns the application. For instance, you can store the contents of "TextBox1" in the resource by reversing the statement and entering the following:
My.Resources.String1 = TextBox1.Text
Press F5 to run the project. The "TextBox1" and "PictureBox1" controls appear on the form along with the button.
Click the button. The code runs, retrieves the .resx resources from the resource file and populates the controls. The image will appear in "PictureBox1," and the text you assigned to the string resource will appear in the text box.
Microsoft Visual Basic is a truly object-oriented programming language, utilizing classes, objects, methods and properties as any other object oriented language. Properties are attributes of a given object and describe the object much as an adjective describes a noun. Methods function as verbs, taking some action on objects and their properties.
Classes
A class is a generic template that can be used to create a specific instance of an object. For instance, the "Car" class has attributes such as "Make," "Model," "color," "Engine size" and others. When you declare a "car" object named "MyNewCar" and give it a name, it inherits the "car" class attributes.
Methods
Methods perform actions on objects, including making changes to the attributes, or properties. A method can add numbers and put the result in the "ResultField" object's text property, or it can change the "Visible" property of a picture object to "False" to prevent the picture from displaying. Methods expect to have parameters passed to them in the correct order, or "signature," and doing otherwise will cause errors.
Objects
An object is a specific occurrence of a class. For instance, you can declare an object named "NewCustomer" and it will inherit the properties of the "Customer" class, including "CustomerName," "CustomerAddress" and "CustomerPhone." Objects function as nouns in that they are things.
Properties
Using the sentence analogy, properties function as adjectives, describing objects. For example, a "CustomerNameTextBoxt" is an instance of the "TextBox" class and has properties such as "Name," "Text," "Location" and others. Sub procedures call methods that act on these properties, making changes to the properties as the program code directs. Properties can be used to change the size and shape of objects in your form application, make them invisible, or hold a numeric value.
Microsoft Visual Basic is a true object-oriented programming language, using classes to define objects and functions to provide code reusability. When properly used, classes provide flexibility and power, and reduce coding time. Functions also reduce coding time, and provide a way for the programmer to avoid building the same code multiple times.
Object-oriented Programming
Object-oriented programming is a philosophy implemented in several different modern languages. One of the main concepts of object-oriented programming is reusable code. This means that you can define something once and then reuse it under another name. It also means creating modular code that can be reused. Classes and functions are two of the main players in achieving these goals.
Visual Basic
Visual Basic versions since VB 6.0 have been true object-oriented languages, implementing many object-oriented concepts and rules. The .NET environment provides a framework of reusable built-in functions and classes, providing an abundant source of robust functionality. In addition, you can build your own classes and functions as you build your projects in Visual Basic.
Classes
Classes are actually somewhat like templates in that they provide the basic properties of an object. For instance, if you build a "Car" class, you would include properties such as "color," "make," "model" and "year." When you build your code, you can create an "instance" of the "Car" class with a statement such as "Dim Chevy As Car," which will contain the default values of the "Car" class. Your program can modify these values as needed.
Functions
Functions are pieces of code that perform actions and return a result. You can pass parameters to functions, but they must be in the exact order expected by the function. An example would be a function to calculate a sales commission. Your program might read through a file of sales associates that contains their monthly sales and commission percentages. Each time you read a new sales associate record, you can pass the monthly sales and commission percentages to one function that calculates pay.
Microsoft's Visual Basic .NET integrated development environment offers lots of features for beginning and experienced programmers alike. VB.NET is intuitive and easy to use, and offers a robust environment for designing and developing Windows applications. Testing and debugging are also much easier in VB than in other programming languages.
Installation
The installation of VB.NET is relatively easy, and can be initiated at the Microsoft Express Download Web site. You will have to select a language preference, and you can either register while installing or skip the registration process until later. You will have 30 days to try the product without registering if you choose to wait until later.
Startup
Start VB.NET the way you would start any other Windows application, by selecting it from the "Programs" list. This opens the IDE and stops on the Start Page. From here, you can select "Create Project" to create a new VB.NET project. When you open a project, you are placed in the Design window, where you build your form from the Visual Basic components.
Build the Form
Using the components in the ToolBox, you can build forms that are simple or complex. The ToolBox contains text boxes, buttons, labels and a number of other components. Drag a component, also called a control, onto the form, or double-click it to place it on the form. Continue to build your form until you have all the controls you need. Place the controls in a logical manner on the form so that a user can look at the form and have an idea of the workflow.
Name the Controls
The default names of the controls do not lend themselves to debugging or program maintenance, so rename them to something meaningful to you and related to what it does in the application. If you have a button that prints, name it "Print_Button" instead of leaving the default of "Button1." You can also change the "Text" property for controls that display text. In the case of the "Print_Button," you should change the "Text" property to "Print."
Code the Program
Even though your form may look really good, nothing happens until you write code for the controls. Double-click on a control such as the "Print_Button" to write code that executes when a user clicks the button. Intellisense is built in to VB.NET, and helps by prompting you with suggestions for finishing whatever you start typing.
Test and Debug
You do not want to send out a "buggy" program to a user, since they will send you error reports when they run into those problems. Use the VB.NET "Debug" menu item to debug you program. You can debug the entire program, or choose to step through it one line at a time. Spending the time to properly test and debug your program will ensure your user of a more positive experience with your application.
Microsoft's Visual Basic .NET, unlike Visual Basic 6.0, is an authentic object-oriented language, with a robust integrated development environment. VB.NET employs classes and objects as part of its object-oriented implementation, providing programmers with the ability to quickly create new objects from existing classes. This can your programming time and help you develop a better application.
Object-oriented Language Characteristics
Object-oriented languages have several characteristics that allow them to be classified as truly object-oriented. One of those is the use of "classes," while another is "reusable code." While the concepts of classes and reusable code are not really new, proponents of object-oriented programming tout these qualities as something novel. Actually, classes have always been around in the form of data definitions, and programmers have been cutting and pasting reusable code for years.
VB.NET
Visual Basic .NET provides you with a solid and robust framework in which their applications can perform. With its array of intrinsic classes and functions, VB.NET provides you with a head start on any application. The IDE facilitates design, coding and testing of applications within the same programming environment, easing the burden on you as you develop your program.
Classes
Classes define generic items, such as customers, inventory items and others. Classes also define data types such as integers, decimals and strings. Each of these data types has properties within the VB.NET environment. Customers, of course, have properties such as "name," "address," and "phone number." In object-oriented terminology these properties are called "attributes." You can define your own classes with attributes as you need them for your program.
Objects
Everything is an object in object-oriented programming. Objects are created from classes and the objects inherit the characteristics of the class. For instance, this statement creates an object named "CurrentCustomer" from the "Customer" class: "Dim CurrentCustomer As Customer." Using the "Customer" class you can create many different customer-type objects for use in your program. You can change the attributes, or properties, of these objects within your program code in Visual Basic .NET.
VB.NET is a full-featured integrated programming environment from Microsoft that provides everything a programmer needs to develop powerful Windows applications. One of its key features is the ability to handle arrays, or multiple occurrences of the same category of object. Arrays are handy for grouping like items and processing them one at a time with a loop. Visual Basic has an array function that aids in processing arrays.
Array Fundamentals
An array is defined as a group of objects that are of the same type, but each object's position in the array is its identifier. One way to picture an array is to look at a table of items with a heading at the top. Each column has a name in the heading telling what is in that column. For instance, consider a table of cars, with the entry number in column one, the car name in column two and the car manufacturer in column three. On each row there is a car name, but each has a different value.
Array Terms
In the example above, each row is an "element" and the numbers are "subscripts." The "boundaries" are the first and last elements. The difference in VB.NET is that the numbers start with zero, meaning the lower boundary is zero, and the upper boundary for subscripts is the number of elements minus one. When you declare the array in VB.NET, you set the upper limit for the array in the "Dim" statement.
Array Declaration
You can declare an array as "Public," "Private" or "Friend," or you can just use the "Dim" statement to declare the array. You can either declare an upper-boundary subscript in the statement or list the actual array values, and VB.NET will figure out the upper boundary. "Dim AutoArray(9)" sets up an array with 10 elements, while "Dim AutoArray As String(4) = {Chevy, Ford, Dodge, Subaru, Toyota}" establishes an array with five predefined items.
Array Subscripts
VB.NET uses subscripts to reference the "rows" in an array of items. The subscript numbers the rows, starting with zero. The subscript for "Toyota" in the array above is four, which is the upper boundary. It is important that you do not overrun the boundaries or you will create an exception, causing your program to fail. The subscript, also called an index, is typically used to process the array using counter variables and looping code, rather than specific references, such as "AutoArray(2)."
Array Processing
To "traverse" an array, you write a loop that takes a look at each row for processing, using a subscript to reference each row. An example of code that would traverse the AutoArray above would look like this:
Dim CarCounter As Integer = 0 'establish a counter for the loop
Dim ItemsInteger as Integer = 4 'set upper boundary for subscript
Do Until CarCounter > ItemsInteger
Debug.WriteLine(AutoArray(CarCounter))
CarCounter += 1 'increment the counter
Loop 'loop again
You can also use a loop like this for searching an array for a specified value.
Go to Microsoft .NET Compact Framework 3.5 Redistributable.
Click on "Download" button under ".NET Compact Framework 3.5 Redistributable" section.
Click on "Save" to save the installation file to your system.
Double-click on the saved file to launch the installation wizard of the .NET Compact Framework 3.5 Redistributable.
Follow the easy guiding prompts of the wizard to complete installation.
Restart your computer.
Make sure you're running a version of Microsoft Internet Explorer that is at least as recent as 5.01. If you're not sure, launch Internet Explorer, click the "Help" menu and select "About Internet Explorer" to see the version number.
Use Internet Explorer to navigate to the download page for Microsoft .NET Framework 1.1 Service Pack 1.
Click the "Download" link at the top of the page and select "Run" when prompted. This will launch the Installation Wizard.
Click the "Next" button in the Installation Wizard. Wait for the progress bar to fill up, then click the "Finish" button at the end of the installation process.
Click the "Restart Now" button if prompted to restart your system after you install the update. If you're not ready to restart the computer right away, click "Restart Later" instead. The security updates will not take effect until you restart the computer.
Make sure you are running Microsoft Internet Explorer version 5.01 or newer. To do this, launch Internet Explorer, click the "Help" menu and then select "About Internet Explorer." The version number will be displayed in the details. If your version is older than 5.01, download the newest version from brothersoft. double click to open the Installation Wizard; follow the on-screen prompts to install the latest release of Internet Explorer.
Navigate to the download location for Microsoft Net Framework 1.1 Service Pack 1 using Internet Explorer.
Click the "Download" button on the Microsoft site. When prompted, click "Run" to launch the Installation Wizard.
Click the "Next" button on the Installation Wizard to begin the installation. Wait for the progress bar to fill up. When the installation finishes, click the "Finish" button on the Installation Wizard.
Click the "Restart now" button if prompted after the installation. If you are not ready to restart at that moment, click the "Restart later" button. The changes will not take effect until the system is rebooted.
Purchase a Microsoft Press book that focuses on the .NET 3.0 framework. Microsoft Press is the official publisher for the .NET references found at any local bookstore or online web store. Microsoft also publishes books for advanced programmers who only need a reference to the libraries.
Complete each practice exam at the back of each book. Many books have practice code and exams that help fortify what you have learned in the chapters. Typing the code into your .NET editor helps you visualize and view the .NET execution.
Use the Microsoft Labs to practice .NET concepts and coding standards. These labs are online classes that run you through programming your first application.
Run the debugger in your code editor. The debugger is the main tool used to troubleshoot any coding issues. The debugger helps you understand how .NET code executes line-by-line. For Microsoft's Visual Studio, you can start the debugger by pressing the F5 key.
Practice several times a week to compound more theories and syntax onto your basic knowledge. Knowing a coding language is similar to learning a regular language. Keep practicing, so you don't lose what you have learned, and you become more familiar with .NET resources.
Click your "Start" menu and click "Control Panel."
Click "Programs" and click "Programs and Features."
Scroll down to "Microsoft .NET Framework." Uninstall each version by clicking the "Uninstall" button on top of the list of programs with each version selected.
free download .NET Framework from brothersoft. Wait for the download to start and choose where to save the file.
Double-click the installer from the location you downloaded it to. Click "Next" and follow the installation instructions until you must click "Finish." Click the button and restart your computer.
An open-loop system, also known as an open-loop controller or a non-feedback controller, is a kind of system that bases the input or start of the system without taking into consideration outside factors directly caused by the system itself. In other words, the feedback caused by the system does not factor into the decision of whether or not the system runs.
Uses
Open-loop systems are used in nearly all walks of life, in everything from washing machines (where the activation of the washing machine is determined simply by a person starting it, not the dryness of the clothes) to cell phones (where the cell phone is turned on and off by the person using it, not depending on whether or not it is actually receiving a call).
Benefits
Benefits of an open-loop system are often the small amount of cost associated with running the processes. It is simpler and more cost effective in most cases simply to start a repetitive process without worrying about factoring in feedback. For example, a process of a conveyor belt works more effectively without having to input feedback of the weight of every specific box that it is conveying. In this case, there is no need for feedback to be taken into consideration.
Drawbacks
Drawbacks of the open-loop system is the possibility of waste, due to the process running when it might not have to, and the fact that the process does not learn from feedback and become more efficient.
Closed-loop system
The opposite of an open-loop system is a closed-loop system. This is a system where the feedback of the process determines the next part of the process. For example, if there is a light that turns on in a room if motion is detected in the room, then that is a closed-loop system since the process of turning on the light entirely depends on feedback, in this case the introduction of motion.
Example
One example of an open-loop system is a sprinkler system that turns on every day at a pre-programmed time. No matter the moisture level of the grass, the sprinkler system will continue to water it at a prescribed time. (For example, even if there was a heavy rain and the sprinklers do not need to be turned on, they will still water at their pre-programmed time.) That is an open-loop because the sprinklers will turn on no matter the feedback (in this case, the grass moisture). However, if someone were to install a moisture detector where the sprinklers only turn on once it reaches a certain point, then the entire system turns into a closed-loop system.
In computer programming, a loop is a series of instructions a computer executes a fixed number of times. An infinite loop is a loop that can run forever unless some external event causes the loop to terminate. Fortunately, most infinite loops do end. However, when they don't, problems can occur and adversely affect an application or the computer that hosts it.
Trivia
"Infinite Loop" is a street that surrounds Apple Computer's corporate office in Cupertino, California. Each of the six buildings that make up the complex has a single-digit address. This unique combination of the computer term "Infinite Loop" and the single-digit address structure used by the company gives Apple an official address of "1 Infinite Loop." The phrase "Infinite Loop" is also the title of a book by Michael Malone that chronicles the beginnings of Apple Computer.
Misconceptions
Many infinite loops are not really infinite. At some point, a process will bring them to a halt. That process could be the shutting down of a browser or even the rebooting of a computer. Programmers sometimes refer to non-infinite loops as infinite. One example of a finite infinite loop is a Web page animation. Using JavaScript, a developer might create a loop that moves an object every few seconds. The loop would execute repeatedly. However, it could eventually terminate if the developer decides to code the program so the animation stops when the object reaches a pre-defined point on the screen.
Coding
The following statement illustrates how a developer creates a regular loop in a program:
loopCounter = 0;
loopLimit = 100;
while loopCounter is less than loopLimit
begin;
(do something);
(add one to loopCounter)
end;
This code says, "While the loopCounter (0) is less than the loopLimit (100), do something." The loop will repeat 100 times. To create an infinite loop, a developer makes sure the value of loopCounter never reaches 100. He could do that by excluding the "(add one to loopCounter)" statement or by replacing the "while loopCounter is less than loopLimit" statement with "while 1 equals 1." If a developer does that, the loop will never end because one will always equal one.
Examples
Timers and clocks on some Web pages sometimes run inside infinite loops. The loop begins when a visitor opens a page and it continues until the visitor leaves the page. Some monitoring applications rely on infinite loop processing to keep an eye on local or remote processes. For example, you could create a Windows Service application that retrieves data from a Web service every hour and stores it in a database.
Warnings
Infinite loops are not hard to create. In fact, some developers create them unintentionally. When this happens, desktop and Web-based applications can loop continuously, consuming large amounts of system resources. The following is an example of a common non-infinite loop defined within a JavaScript function:
var loopLimit = 100;
for (var i=0; i< loopLimit; i++) {
// do something
}
This loop will "do something" until it reaches the limit set by the variable, "loopLimit." In this example, the loop will run 100 times. However, what happens if the value of loopLimit gets incremented by some other function? If that occurs, the loop might never end. Developers should be aware of this common programming error. Other unintentional loops can occur if a developer relies on some external event, such as a mouse click, to stop the loop and that event fails to happen.
A computer programming loop executes an iterative process that runs a finite number of times (n). Set a variable i, known as the loop variant, and perform a test called a termination check. If the test evaluates to true, then the loop will terminate.
A simple example loop prints the numbers from 1 to 10. Create a loop variant i and set the value to 1. On each iteration of the loop, print the current value of i and increment i by 1. The termination check will end the loop if i is greater than 10 at the end of the loop body.
i = 1
loop
print i
i = i + 1
if i <= 10 then goto loop
However, a few common programming errors will result in infinite loops that can hang your program.
Not Changing the Loop Variant
The termination check relies on the loop variant i getting closer to the termination condition. If the loop variant stays constant and doesn't change, then the termination check will always fail and the loop will continue indefinitely.
This problem will also occur if the loop variant depends on an unaccounted-for condition. Suppose your program prints every number between 1 and 5, then 7, then terminates. Your loop might look as follows:
i = 1
loop
print i
if i < 5 i = i + 1 (increments the loop variant, prints the numbers 1 through 5)
if i <= 7 goto loop (resets the loop for values of i less than or equal to 7)
In this loop, when i reaches 5, the loop will restart without ever incrementing and print 5 forever. The program must include a line that changes the loop variant.
i = 1
loop
print i
if i < 5 i = i + 1 (increments the loop variant, prints the numbers 1 through 5)
else i = i + 2 (increments by 2 when i reaches 5)
if i <= 7 goto loop (resets the loop when i reaches 7)
This loop will terminate after i reaches 7.
Resetting the Loop Variant
You may set a command in the middle of the loop body that resets the loop variant and creates an infinite loop. For example:
loop
i = 1 (resets the loop variant to 1)
print i
i = i + 1
if i < 5 goto loop
This sets i back to 1 at every iteration, yielding an infinite loop.
Setting the Loop Variant to Go Away from the Termination Condition
The loop variant must go toward the termination condition on each iteration.
i = 1
loop
print i
if i = 2 then i = i - 1
i = i + 1
if i < 3 goto loop
In this example the loop will hang when i reaches 2. You might make this kind of mistake when writing complicated loops like string parsing.
Setting an Incorrect Termination Condition
i = 1
loop
print i
i = i + 1
if i > 0 goto loop
In this example, the termination condition will cause an infinite loop as i increases without limit on every iteration.