Discover millions of ebooks, audiobooks, and so much more with a free trial

Only $11.99/month after trial. Cancel anytime.

ASP.NET and VB.NET in 30 Days: Acquire a Solid Foundation in the Fundamentals of Windows and Web Application Development
ASP.NET and VB.NET in 30 Days: Acquire a Solid Foundation in the Fundamentals of Windows and Web Application Development
ASP.NET and VB.NET in 30 Days: Acquire a Solid Foundation in the Fundamentals of Windows and Web Application Development
Ebook532 pages19 hours

ASP.NET and VB.NET in 30 Days: Acquire a Solid Foundation in the Fundamentals of Windows and Web Application Development

Rating: 0 out of 5 stars

()

Read preview

About this ebook

The book teaches the essentials of VB.NET and Active Server Pages (ASP.NET) in about four weeks. This book promises to be an excellent resource for novices interested in learning the essentials of ASP.NET, VB.NET, Windows applications, and online apps.

Using examples, this book teaches how to declare variables, operators, and control statements in C++. Standard window controls like Listboxes, Comboboxes, Checkboxes, Radio buttons, Timers, Scrollbars, and Picture boxes are explored and elaborated. The basics of Database Management using VB.NET and ASP.NET are demonstrated through instructive examples. Topics like HTML, CSS, and JavaScript are also addressed in detail in the book. Readers will understand the fundamentals of front-end programming, but they will also gain an understanding of the concept of back-end programming.

Topics of Arrays, functions, databases, sessions, and file upload control are covered with practical exercises and use-cases scattered throughout. After reading this book, students will be very familiar with the VB.NET and ASP.NET programming examples and can successfully transition themselves into a professional developer.
LanguageEnglish
Release dateMay 13, 2022
ISBN9789355511157
ASP.NET and VB.NET in 30 Days: Acquire a Solid Foundation in the Fundamentals of Windows and Web Application Development

Related to ASP.NET and VB.NET in 30 Days

Related ebooks

Software Development & Engineering For You

View More

Related articles

Reviews for ASP.NET and VB.NET in 30 Days

Rating: 0 out of 5 stars
0 ratings

0 ratings0 reviews

What did you think?

Tap to rate

Review must be at least 10 words

    Book preview

    ASP.NET and VB.NET in 30 Days - Dr. Pratiyush Guleria

    CHAPTER 1

    Introduction to .Net Framework

    Introduction

    .NET framework is a software development platform developed by Microsoft. With the help of the .NET framework, we can develop Window-based and web-based applications, web services, and so on. The Window-based applications are developed using VB.NET and C#.NET, whereas ASP.NET web-based applications are developed using either VB or C# syntax. In .Net, programming languages like HTML, Visual Basic, C#, and Visual C++ are already built into the integrated development environment. The main components of the .Net framework include .NET class libraries, Common Language Runtime (CLR), Common Type System (CTS), language interoperability, and so on.

    Structure

    In this chapter, we will cover the following topics:

    Know about .NET framework

    Understanding CLR

    Know about Microsoft Intermediate Language (MSIL)

    Introduction to Visual Studio.NET

    Objective

    The objective of this chapter is to get familiar with the .NET framework and the programming environment using Visual Studio .NET. In Visual Studio .NET, the desktop applications and websites can be developed using Visual Basic or C# syntax. After studying this chapter, you will be able to execute a simple example in Visual Studio .NET and learn about the variable declaration in VB.NET using Visual Basic as the programming syntax.

    What is .NET framework?

    The .NET platform is a new development framework that provides a fresh application programming interface (API) to the services and APIs of the classic Windows operating system. It consists of the following:

    The ASP web development framework.

    A commitment to XML and object-oriented design.

    Support for new web services protocols such as Simple Object Access Protocol (SOAP), Web Service Definition Language (WSDL), and Universal Description Discovery and Integration (UDDI).

    A set of languages, including C# and Visual Basic .NET.

    A set of development tools, including Visual Studio .NET.

    A comprehensive class library for building web services and Windows applications; as well as the Common Language Runtime (CLR) to execute objects built within this framework.

    Specialized functionality for relational data storage, E-mail, B2B commerce, and so on.

    New .NET enabled non-PC devices, from cell phones to game boxes.

    Microsoft .NET supports not only language independence, but also language integration. It supports object-oriented programming. We can inherit from classes and catch exceptions, and take advantage of polymorphism across different languages. The .NET framework is shown in Figure 1.1:

    Figure 1.1: The .NET framework

    The current version of the .NET framework is 4.8 and the integrated development environment for developing Window and web-based applications is Microsoft Visual Studio. The latest product name is Microsoft Visual Studio 2019, and it supports the .NET framework 3.5 to 4.8.

    Common Type System (CTS)

    CTS is a specification by Microsoft for using data types in the .NET framework. It specifies the type definitions and their representations in computer memory.

    In .NET, there are classes and objects. The .NET is an object of a specific class that inherits from the root class called System.Object. The common type system supports the general concept of classes, interfaces, and so on.

    Common Language Specification (CLS)

    .NET specifies the language features supported by the Common Language Runtime (CLR) of the .NET framework. It defines those features that are supported by all languages that target CLR. CLS provides a set of basic rules required for language integration. The Framework Class Library (FCL) is the collection of class libraries which can be used by any language that comply with the CLS.

    The .NET framework consists of the following:

    Four official languages – C#, VB.NET, managed C++, and JScript .NET

    Common Language Runtime (CLR)

    An object-oriented platform for Windows and web development that all these languages share

    A number of related class libraries, collectively known as the Framework Class Library (FCL)

    Understanding Common Language Runtime (CLR)

    CLR is the most important component of the .NET framework which provides the environment in which programs are executed. Its features include the following:

    The CLR includes a virtual machine, in many ways similar to the Java virtual machine.

    The CLR service includes memory management, exception handling, type checking, security checks, and garbage collection.

    It supports features of object-oriented programming.

    It loads the classes.

    CLR converts the Microsoft Intermediate Language (MSIL) code just like Byte codes in Java into native machine codes.

    Know about MSIL

    In .NET, the programs are not compiled into executable files directly like in other high-level languages such as C, C++, and so on. Here, they are compiled into Microsoft Intermediate Language (MSIL) files, which are then executed by Common Language Runtime (CLR) during runtime.

    In CLR, as the name specifies, common language runtime means the same runtime environment supports C sharp development as in VB.NET.

    When the project is built, the code is compiled into intermediate language first, which is saved in a file on the disk. Upon running the program, the intermediate language file will be again compiled by the Just-in-Time (JIT) compiler and converted into machine code. This machine code executed by the machine makes the .NET environment platform independent and the compiled code can be reused on heterogeneous platforms. Here, Common Language Specification (CLS), as explained earlier, specifies that all .NET languages produce very similar intermediate language codes. As a result, objects created in one language can be accessed and derived from another. For example, the base class created in VB.NET can then be derived in C#.

    Starting Visual Studio.NET

    In the Visual Studio .NET environment, there are mainly four components, that is, Form Design Window, Toolbox, Solution Explorer, and Property Window. In Form Design Window, we drag and drop the controls from the toolbox and set the properties of controls from the Property window. In Solution Explorer, there are files related to the Windows application. It contains code window, designer view, and other files related to the project. The Windows Form Application page is depicted in Figure 1.2:

    Figure 1.2: Windows Form Application

    The components of VB.NET environment are shown in Figure 1.3:

    Figure 1.3: Components of VB.NET Windows Application

    Dragging and dropping the controls on Form Window and setting the properties

    The first step is to start the Visual Studio .NET and then select the New Project… option, as shown in Figure 1.4:

    Figure 1.4: Start the Visual Studio.NET project

    Now, select Windows Forms Application from the File menu, as shown in Figure 1.5:

    Figure 1.5: Select Windows Forms Application and Visual Basic as the language syntax

    The next step is to drag and drop the controls from the toolbox on the Form Design Window and then, set the property of the control like text color, font, or any other required property in the Properties window section, as shown in Figure 1.6:

    Figure 1.6: Different sections of the Windows Forms Application and setting the properties in Property window section

    Conclusion

    In this chapter, we discussed the .NET framework in detail, followed by an introduction to the Integrated Development Environment (IDE) of Visual Studio .Net.

    In the next chapter, we will cover the topics related to the variable declaration, operators, control statements, and common window controls with the help of suitable examples.

    Questions

    Discuss the .NET framework in detail.

    What do you mean by CLR, CTS, and MSIL?

    Key terms

    In VB.NET, VB means Visual Basic. VB is an event-driven programming language, that is, action is performed. For example, event can be fired on the click of a button, keyboard, or any other control.

    CLR is known as the Common Language Runtime.

    MSIL is known as Microsoft Intermediate Language. The code is first converted into MSIL, and then it is converted into machine language.

    The controls are dragged from the toolbox in VB.NET and dropped on the Form Design Window. The properties of the controls are set in the Property window.

    CHAPTER 2

    Variables, Control Statements, and Common Window Controls

    Introduction

    This chapter covers the topics related to variable declaration followed by operators. The concepts of if, nested-if conditions, and loops are illustrated with examples. Common window control, that is, ListBox, ComboBox, Scrollbars, Timers, and PictureBox are also discussed with suitable examples.

    Structure

    In this chapter, we will cover the following topics:

    Variable declaration

    If, Nested-If condition

    Loops

    Common window controls

    Objective

    After studying this chapter, you will be able to learn about the variable declaration and implement the logics using if condition and loops wherever it is necessary. Apart from it, you will be able to learn about using the common window controls on Form Design Window, the properties, and the predefined methods of the controls.

    Know about variable declaration

    In programming, the initial step is to start with a variable declaration.

    In VB.Net, the dim keyword is used to declare a variable. Dim means dimension. A variable can be declared as integer, float, double, string, date, Boolean, and so on.

    The syntax of variable declaration is as follows:

    Dim i as integer = 429 //here, variable is declared as Integer

    Dim student as String = Sunil //here, variable is declared as String

    Example 2.1: Program for variable declaration

    Let's look at a program for variable declaration following step-by-step procedure in VB.Net Integrated Development Environment (IDE), as follows:

    First, open a new project in Microsoft Visual Studio.Net, as shown in Figure 2.1 and then open Windows Forms Application:

    Figure 2.1: Windows Form Application

    The form window will be opened, as shown in Figure 2.2. The components are as follows:

    Solution Explorer

    Property Window

    Toolbox

    Form Design Window

    Figure 2.2: Components of VB.Net Windows Application

    In the next step, drag three labels along with textboxes and one button. The properties of the label, textbox, and button control is to be set in the Properties window, as shown in Figure 2.3:

    Figure 2.3: Setting the properties of controls drag and drop on form

    The complete design of form window consisting of three labels, three textboxes, and one button is shown in Figure 2.4:

    Figure 2.4: Form design

    Now, perform the coding on the button click event, as shown in Figure 2.5:

    Figure 2.5: Code section

    In the coding part, variables a, b, and sum are declared as integer. The result is displayed in the TextBox3. In this example, string concatenation operator & is used to concatenate the string.

    The code is as follows:

    Public Class Form1

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

    Dim a, b, sum AsInteger

    a = TextBox1.Text

    b = TextBox2.Text

    sum = a + b

    TextBox3.Text = The Sum is & sum

    End Sub

    End Class

    Now, finally run the program, as shown in Figure 2.6 or press Ctrl + F5 to run the program without debugging:

    Figure 2.6: Debug the program

    The output on the click event of button is shown in Figure 2.7:

    Figure 2.7: Output window

    Example 2.2: Example of String variable

    Next, let's look at an example of String variable.

    In this example, only one button is to be dragged from the toolbox and the program is to be written on the click event of button. On the button click event, variables firstname, lastname are declared as String type and the output is stored in the wholename variable after string concatenation, as shown as follows:

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

    Dim firstname, lastname As String

    Dim wholename As String

    firstname = Pratiyush

    lastname = Guleria

    wholename = firstname & lastname

    MessageBox.Show(wholename)

    End Sub

    MessageBox.Show() is the dialog box to display the message.

    In Example 2.2, the variables are declared as Strings and string concatenation operation is performed using the & operator. The output of Example 2.2 is shown in Figure 2.8:

    Figure 2.8: Output window of dialog box

    Operators

    Operators are used for performing some mathematical and logical operations. We perform operations on the operands using the following operators:

    Arithmetic operators: With the help of arithmetic operators, we perform operations like addition, subtraction, division, multiplication, modulus, that is, remainder and power, and so on.

    Comparison operators: As the name signifies, comparison operators perform operations like greater than, less than, equal to, greater than equal to, less than equal to, and so on.

    Logical operators: These operators are implemented to perform logical operations like Logical AND, Logical OR, NOT, XOR, and so on. With the help of these operators, conditions are checked, and Boolean value is returned, that is, either True or False.

    Bitwise operators: Bitwise operators are used to perform the Binary operations just like logical operators such as Logical AND, Logical OR, NOT, and XOR, and so on. The output value after performing operations need to be converted into decimal equivalent of the Binary value obtained. The symbols of Bitwise operators are AND (&), OR (|), and XOR (^).

    Assignment operator: As the name of the operator signifies, it assigns the value to the operand. For example, if we write x+=10 or x-=10, these values can be rewritten as x = x + 10, x = x - 10 and the result will be stored in the left operand.

    Example 2.3: Write a program for arithmetic operators

    In this example, three variables a, b, c are declared using the Dim statement on the button click. The value in the textbox is converted into Integer type using Integer.Parse(). Here, Integer represents a 32-bit signed integer and Parse() is an inbuilt function that converts the string representation of a number to its 32-bit signed integer equivalent. The design window of arithmetic operators of this example is shown in Figure 2.9:

    Figure 2.9: Design window of Example 2.3

    The code is as follows:

    Public Class Form1

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

    Dim a, b, c As Integer

    a = Integer.Parse(TextBox1.Text)

    b = Integer.Parse(TextBox2.Text)

    c = a + b

    TextBox3.Text = c.ToString()

    End Sub

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

    Dim a, b, c As Integer

    a = Integer.Parse(TextBox1.Text)

    b = Integer.Parse(TextBox2.Text)

    c = a - b

    TextBox3.Text = c.ToString()

    End Sub

    Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click

    Dim a, b, c As Integer

    a = Integer.Parse(TextBox1.Text)

    b = Integer.Parse(TextBox2.Text)

    c = a / b

    TextBox3.Text = c.ToString()

    End Sub

    Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click

    Dim a, b, c As Integer

    a = Integer.Parse(TextBox1.Text)

    b = Integer.Parse(TextBox2.Text)

    c = a Mod b

    TextBox3.Text = c.ToString()

    End Sub

    Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button5.Click

    Dim a, b, c As Integer

    a = Integer.Parse(TextBox1.Text)

    b = Integer.Parse(TextBox2.Text)

    c = a * b

    TextBox3.Text = c.ToString()

    End Sub

    End Class

    Example 2.4: Write a program for relational operators

    The relational operators are used with the if-else structure to perform comparisons. The design window of relational operators of this example is shown in Figure 2.10. In this example, variables are declared using Dim on the click event of the button. Here, if condition is used to check the value of a and b using the relational operator mentioned on the button click event. The Boolean value in the form of true and false is returned and the message box is displayed.

    The code for this example is as follows:

    Public Class Form2

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

    Dim a, b As Integer

    a = Integer.Parse(TextBox1.Text)

    b = Integer.Parse(TextBox2.Text)

    If a = b Then

    MessageBox.Show(Value of a is equal to b)

    Else

    MessageBox.Show(Value of a is not equal to b)

    End If

    End Sub

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

    Dim a, b As Integer

    a = Integer.Parse(TextBox1.Text)

    b = Integer.Parse(TextBox2.Text)

    If a > b Then

    MessageBox.Show(Value of a is greater than b)

    Else

    MessageBox.Show(Value of a is less than b)

    End If

    End Sub

    Private Sub Button3_Click(sender As Object, e As EventArgs) Handles Button3.Click

    Dim a, b As Integer

    a = Integer.Parse(TextBox1.Text)

    b = Integer.Parse(TextBox2.Text)

    If a

    Enjoying the preview?
    Page 1 of 1