Today we will learn about Visual Studio Community 2015. Computers have become an integral part of modern civilization. In our day-to-day life, millions of computers are running endless applications to meet our personal, social and professional needs. We commonly find different computer applications like Feedback, Form, Build Generation, Customer Database, etc. running at shopping malls, banks, reservations, counters, hotels, schools, etc.
These computer applications are created by using different programming languages. A programming language is a special language that programmers use to communicate with a computer. Programming languages have the ability to perform complex operations and provide an attractive and user-friendly interface to work upon. Let's know the fact.
Alan Cooper is widely recognized as the father of Visual Basic. Ok, let us first understand what is Visual Basic VB. Visual Basic is a programming language that is popular among the beginners. It was developed by Microsoft in May 1991. VB was designed with the beginner programmers in mind and for those programmers who needed to develop visual elements in their programs.
VB is based on the basic language and provides a variety of tools to create user-friendly applications with graphical user interface. That is why it is called Visual Basic. It helps in creating the event-driven applications which encourage higher user interaction through icons, menus, pointers, buttons, dialog boxes, etc.
It chooses to modify pre-selected sections of codes and facilitates beginners to create their own computer programs instantly. Since its release, VB rolled out different versions 1.0, 2.0, 3.0, 4.0, 5.0 and 6.0. After VB 6.0, it moved to.NET framework and Visual Basic became Visual Basic.NET.
Few more versions of.NET were released such as Visual Basic,.NET 2003, Visual Basic 2010, Visual Basic 2012 and Visual Basic 2013. In 2015, Microsoft released another enhanced version of Visual Basic named as Visual Basic 2015 with many new features primarily meant for building mobile applications. Ok, note. The.NET portion was dropped from the name of Visual Basic in 2005. Ok, let's know more.
An object-oriented programming is an art of dividing the large programs into self-contained blocks, objects that work independently to complete the task. You can understand this concept with an example of computer. A computer consists of various objects like monitor, keyboard, mouse and CPU.
all together in a combined way forming a computer system but each of them work independently. Okay let us take a look at the introduction to Visual Studio Community 2015. Visual Basic 2015 is a part of Microsoft Visual Studio Community 2015 package. Visual Studio Community 2015 is a free fully featured object-oriented programming language that is designed for individual developers open source projects academic research education and small professional teams we can create applications for Windows Android and iOS as well as web applications and cloud services let's know the fact Visual Basic 2015 is bundled together with other Microsoft programming languages C hash C++, FHash, JavaScript, Python and more in a package called Visual Studio Community 2015. Ok, let us talk about Event Driven Programming. While using an application, a user normally performs actions such as pressing a key, clicking a mouse, selecting a checkbox or a list item etc. Such actions are known as Events.
In event-driven programs, the statements are not executed in the sequence in which they are written. They only get executed when a corresponding event occurs. For example, in the given scenario, clicking on the enter and exit buttons are two different events.
When we click any one of them, it executes the task associated with it, whereas the statements associated with the other button are not executed. Okay, let's know more. In Visual Studio 2015, light bulbs displayed in the left margin of the Visual Studio Editor window provide line code analysis, that is, These tell that the compiler has detected an issue, if any, in the code and also suggest how to fix it. Alright, let's now talk about the modes of a Visual Basic program.
A Visual Basic program has three modes. Design mode. It is used to create objects and write logical statements for Visual Basic applications. In this mode, the programmer plays a very important role.
Run Mode. This is a mode in which the statements written by a programmer are only executed and the application performs the task for which it has been designed. Break Mode. When an application generates errors or does not give the desired results, the execution pauses for the user to remove the errors. This mode is called the Break Mode.
Let us now learn how to start Visual Basic 2015. To start Visual Basic 2015, click on Start, then All Apps, then Visual Studio 2015. The Start page of Visual Studio appears. The Visual Studio Start page consists of a few panes, namely Start. It provides some helpful options to develop the applications like New Project, Open Project, Open from Source Control, Recent. It displays the list of projects that have been created by you in the recent past.
News It provides the latest online news as well as releases and updates from the different components of Visual Studio 2015. New on Microsoft Platforms It offers you various platforms to create an application in Visual Studio. Featured Videos In this section, you will find a list of featured videos created by Microsoft. These videos are useful to get familiar with various tools and development environment. Click on the New Project option in the Start section. The New Project window will appear.
Select the Visual Basic in the left pane and choose the Windows Forms Application option in the middle pane. Click OK. The following window will appear.
Ok, let me give you a tip. You may specify the name of the application in the name box or you can choose to save it later. Visual Studio 2015 window contains the menu bar, tool bar, tool box and some other windows. Such as the form window, solution explorer window, properties window and the error list etc.
Visual Studio 2015 integrated development environment bundles all these tools and provides us an interface where we can design, edit, compile and execute the application on a single platform. Ok, let us discuss on the components of the Visual Basic 2015. Title Bar The title bar is present at the top of the window and displays the name of the currently opened project. Menu Bar Menu bar contains many menu items and sub-menus. These items give access to various options which help in developing the application.
Toolbar Toolbar contains icons that give access to frequently used menu items. These icons acts as shortcuts to the options available in the menu bar. Form window Form is an interface through which an user interacts with the application.
A form contains many control elements such as label, text box, button, etc. Using these controls, a user can enter data and give instructions to the application. The form window provides us with the blank form where we can place various controls as per our requirements. Properties window Properties are the attributes that define the appearance and behavior of objects, forms and other controls.
Forms have many properties such as name, font, color, border style. Padding, Size, Text, etc. The Properties window consists of an object drop-down list and the list of properties. This window is used to set the properties of forms and the other controls placed on them.
The bottom section of the Properties window shows a description of the selected property. Solution Explorer This window displays a list of forms and other objects that constitute the application. This list is organized in the form of a branching structure like Windows Explorer.
To open any object, we can double-click on its icon in the Solution Explorer window. Toolbox As the name suggests, the toolbox contains various controls such as button, text box, label, etc. These controls can be added to the forms by dragging and placing them at the desired location. Code Window Code Window is used to write code. codes for any object.
To write codes, double click the object on the form. This action opens the code window where we can write the required visual basic statements. Ok let us take a quick view. Press F7 key to open the code window.
Let me now tell you how to develop a VB application. To develop an application using VB2015, follow the given steps. Build an interface by adding controls to the form. Set properties of the controls.
Write codes on various events of added controls and run the application. Let's know the facts. VisualBasic.net is an evolution of the Visual Basic language and is targeted to develop Windows, web and mobile devices based applications.
Building an interface. When we start a new project in Visual Basic 2015, a blank form appears on the screen. We can add more forms to our application by either clicking on the Project then Add Windows Form and then Windows Form or selecting the Project then Add New Item then Windows Form option. You can also resize the form by dragging any corner of the form.
Adding controls to the form To add a new control to the form, follow the given steps. Click on the desired control in the toolbox and bring the pointer on the form. The pointer will change to crosshair plus symbol. Move the pointer to the desired location and drag it to draw the selected control.
Or double click on the control in the toolbox. The control gets placed on the form. Or drag the control from the toolbox and drop it onto the form. We can change the size, shape and location of the control as per our requirement. Okay, let us take a quick view.
Press Ctrl plus Shift plus A key combination to add a new form in the project. Setting Control Properties Let us learn to set properties of any control. Select the control in the form whose property you want to set.
The properties related to that control will appear in the Properties window. Click on the desired property. Reset the property and observe the changes in the control. Commonly used controls Label A label is used to display descriptive text for a control.
Let us learn the common properties of label control. Name The name property identifies a label while writing the program. Font This property sets the font, font size, font style, etc. for the label. For color, this property changes the foreground color of the label used for displaying the text. Text, this property is used to display the text on the label.
Visible, this property determines whether the control is visible or hidden. Text box, a text box is used to receive input from the user. We can enter text and numbers in this box.
The common properties of the text box control are Name The name property identifies the text box while writing the program. Text This property is used to display the text in the text box. Font This property is used to set the font size, font, font style etc. for the text box. Locked This property determines whether we can move or resize the control. Max Length This property is used to set the maximum length of the text that can be entered in a text box.
Multi-line This property decides whether the text will be displayed in a single line or in multiple lines. By default, this property is set as false. Button The button is used to raise an event in the application. When a user clicks on the button, the programming statements associated with that button gets executed.
The common properties of button control are Name The name property identifies a button while writing the program. Text. This property is used to display the text on the button. Font. This property sets the font size, font, font style etc. for the button.
Ok, let's know more. PHP stands for Hypertext Pre-Processor. It is a widely used open source general purpose scripting language.
specially suited for web development. Alright, let me now tell you how to write codes for an event. Follow the given steps to write programming statements for any event. Here we are considering the click event of a button control. Click on the text box control in the toolbox.
Now select the button control from the toolbox and place it on the form. A button will appear and it will have button 1. as its name. Change its name to display using the text property.
Double click on the display button to open the code window. In the code window, write the statements in between the pre-written lines of code as shown in the figure. Explanation In our example, we are assigning some text value to the label. The value is assigned to the label when the button is clicked in the runtime.
The syntax to assign a value to the property of an object is object.property equals to value. Let us now find out how to execute Visual Basic 2015 project. There are three ways to run a Visual Basic project. Press F5 key on the keyboard or select the Start Debugging option in the Debug menu or click on the Start button on the standard toolbar. You can do both display text as well as accept text from users by using a text box control.
After a user types data in a text box, you can retrieve this data by using the text property. Example, create the program to view the message using text box control. Drag the text box control from the toolbox panel onto the form.
Similarly, add a button control next to the text box and change its text property to retrieve. Double click on the retrieve button to add the following code. Public class form 1. Private sub button 1 underscore click.
Bracket in sender as object. E as event args bracket close handles button 1 dot click message box dot show bracket in text box 1 dot text bracket close end sub end class. Press F5 to run the program.
Type multiple lines of text in the text box and then click on the retrieve button. Example, create an application to add two numbers and display the output in their respective text boxes. Select a new project, add three labels, three text boxes and one button in the blank form. Arrange them as shown in the figure.
Chain the properties of the control as given in the following table. Label 1 Text, enter first number, font 12, bold. Label 2. Text, enter second number, font 12, bold. Label 3. Text, sum of given numbers, font 12, bold. Text box 1. Text, empty, font 12, bold.
Text box 2. Text empty. Font 12. Bold. Text box 3. Text empty. Font 12 bold. Button 1. Text calculate.
Font 12 bold. After applying these properties, write statements for the click event. Double click on the calculate. The code window will open. Write the code as shown in the figure.
Press F5 to run the application. You will see the form on the screen. Enter two numbers in text box 1 and text box 2 respectively and click on the calculate button.
You will get the result of the operation in text box 3. Ok, let us understand variables in Visual Basic. A variable refers to a named memory location used to store data temporarily. It has a unique name which is used to identify it in the program.
Every variable has an associated data type such as string, integer, etc. to specify the type of data it can hold. Dim statement is used to declare a variable in Visual Basic. Dim variable name as data type. For example, the dim radius as integer will create a variable named as radius to store the integer values.
Data type, description, example. Data type, integer, description. It is used to store integer values ranging from minus 327682 plus 32768. Example, dim marks as integer.
String. It is used to store a set of characters. Dim name as string.
Date. It is used to store data based on date and time. Dim, D-O-B as date.
Example 3. Create an application to calculate the area and circumference of a circle using variables. Start a new project. Add three text boxes. and two labels in the form. Add two buttons and change the following properties.
Name, CMD Calc. Text, Calculate. Name, CMD Clear.
Text, Clear. Type the following code for the buttons. Public Class Form 1. Private Sub.
cmd calc underscore click bracket in center as object e as event arcs bracket close handle cmd calc dot click dimension radius as integer dimension area as integer dimension circumference as integer these statements will create three integer type variables to store values of radius area and circumference Radius equals to value bracket in text box 1 dot text bracket close. Variable radius will get value from text box 1. Area equals to 3.14 multiply radius multiply radius. Circumference equals to 2 multiply 3.14 multiply radius. These statements will calculate the area and circumference using the value of radius variable.
and store the result in variable area and circumference respectively. label1.text equals to double quote in area double quote close. textbox2.text equals to area. label2.text equals to double quote in circumference double quote close. textbox3.text equals to circumference.
These statements will display the value stored in variables area and circumference in text box 2 and text box 3 respectively. End Sub Private Sub cmd clear underscore click Bracket in center as object e as event args bracket close Handle cmd clear dot click Text box 1 dot text equals to double quotes Text box 2 dot text equals to double quotes Label 2 dot text equals to double quotes. Text box 3 dot text equals to double quotes.
Label 3 dot text equals to double quote. These statements will clear the text written in text box 1, text box 2 and text box 3 respectively. End sub, end class.
Note, declaring a variable means reserving the money space for it. It is not required to declare a variable before using it. Whenever Visual Basic encounters a new variable, it assigns the default variable type and value to it.
This is called implicit declaration. Although this type of declaration is easier for the user as it gives control over the variables, yet it is advisable to declare them explicitly, which is called explicit declaration. For explicit declaration, use the statement option explicit before the variable declaration. Let us discuss on operators in Visual Basic.
Operators are special symbols used to perform calculations, make comparisons and check logical conditions in a program. Some of the major categories of available operators in VB are given below. Arithmetic Operators These operators are used for arithmetic operations.
Operator, description, example, results. Operator, plus, description, add. Adds two values.
Example, 18 plus 4. Results, 22. Minus, subtract. Subtracts one number from another. 18 minus 4. 14. Divide. Divide.
Divides one number by another. 18 divided by 4. 4.5. Multiply. Multiply. Multiplies two numbers.
18 into 4. 72. Integer division. Integer division. Displays only the integer questioned.
Without decimal places. 18 divided by 4. 4. Percentage. Modulus.
Returns the remainder from the division operation. 18 percentage 4. 2. Relational operators. These operators compare two values and return true or false as a result.
Operator. Description. Example.
Result. Operator. Greater than. Description, greater than, checks whether a number is greater than the other number or not.
Example, 5 greater than 4. Result, true, less than. Less than checks whether a number is less than the other number or not. 4 is smaller than 7. True, equal to, equal to, checks whether a number is equal to the other number or not. 4 equals to 5. False.
Greater than equal to. Greater than or equal to. Checks whether a number is greater than or equal to the other number or not.
8 is greater than equal to 4. True. Less than equal to. Less than or equal to.
Checks whether a number is less than or equal to the other number or not. 7 is smaller than or equal to 7. True. Not equal to. Not equal to.
This operator returns true if the numbers are not equal. 4 is not equal to 6. True. Logical operators.
These operators are used to combine two or more conditions and display the result accordingly. Operator. Description.
Operator. Or. Description. To check whether any of the given conditions is true or not. It will return true if any of the conditions is true.
And To check if both the conditions are true or not. And returns true only if both the conditions are true. Not Returns true if none of the conditions is true.
Let us learn how to say Visual Basic Project. Let us learn how to save a Visual Basic 2015 project. Click on the file then save form1.vb as option.
The save file as dialog box will appear. Choose the location where you want to save your form. Enter the name for the form in the File Name text box and click on the Save button. Ok, now let us learn how to close a Visual Basic project.
Click on the File then Close solution. A window appears asking Save Changes to the following items. Click on the Yes button or you can simply click on the Close button to close the project.
Okay, now let us find out how to open an existing project. To open an existing project in Visual Basic 2015, click on the File Then Open Then Project Solution option. The Open Project dialog box appears.
Find the project and select it. Click on the Open button. The selected project will open.
Choose the form which you want to open and click on the Open button again.