Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
44 views

Computer Programming VB - Net.docx 2

The document discusses computer programming and translation of programming languages. It explains that machine language uses binary, programming languages resemble human language, and all languages must translate to machine code. Interpreters translate line by line while compilers translate all at once before running.

Uploaded by

Raleen Gener
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
44 views

Computer Programming VB - Net.docx 2

The document discusses computer programming and translation of programming languages. It explains that machine language uses binary, programming languages resemble human language, and all languages must translate to machine code. Interpreters translate line by line while compilers translate all at once before running.

Uploaded by

Raleen Gener
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 5

Computer Programming

Machine language – a series of ones and zeroes


Programming languages – languages used to communicate to computers that are similar to human language.
High-level – similar in format to the way humans communicate with each other
Low-level – languages that are like or nearer in format to machine languages
Translation of Programming Languages
Whatever the programming language, translation into machine language format is still needed. There are 2 types of
program that perform translation:
Interpreter – a program that translates high-level instructions into machine code, line by line, as the program is
being run
Compiler – translates all high-level instructions into machine code first before running the program

User Interface Elements


The .NET Framework has two components:
Class library – a comprehensive, object-oriented collection of reusable types that you can use to develop
applications ranging from traditional command-line or graphical user interface (GUI) applications based on the
latest innovations provided by ASP.NET, such as Web Forms and XML Web services.
Common language runtime – provides functionality such as exception handling, security, debugging, and versioning
support to any language that targets it
Translating Multiple Languages into a Common Language
The process of compiling and executing managed code is given below:
1. When you compile your Visual Basic .NET program, the compiler translates your source code into
Microsoft Intermediate Language (MSIL) or Intermediate Language (IL). No matter which language has been used to
develop the application, it always gets translated into IL. This ensures interoperability.
2. The compiler creates the .exe or .dll file.
3. When you execute the .exe or .dll file, the code (converted into IL) and all the other relevant information
from the base class library are sent to the class loader. This loads the code in the memory.
4. Before the code can be executed, the .NET Framework needs to convert the IL intonative or CPU-specific
code. The Just-In-Time (JIT) compiler translates the code from IL into managed native code.
5. After translating the IL into native code, the converted code is sent to the .NET runtime manager.
6. The .NET runtime manager executes the code.

Working with Forms and Controls


Form – a window on which you can design your user interface,i.e., the window you normally interact with
Controls – make up the design of your form. The Run button in your video game, the Download button in iTunes, and
the Send button in your cell phones are just some of the examples of controls.
How to Create a Form
1. If the Solution Explorer is not open, on the View menu, click Solution Explorer.
2. In the Solution Explorer, right-click the project name, point to Add, then click Add Windows Form.
3. In the Add New Item dialog box, set an appropriate name for the form and click Open.
How to Add Controls to a Form
1. If the Toolbox is not open, on the View menu, click Toolbox.
2. Double-click the Toolbox icon of the control you want to add. This places an instance of the control at the
default size in the upper-left corner of the active object. When adding multiple controls in this manner, they are placed
on top of each other.
3. After the controls are added, you can reposition and resize them.
a. To reposition the control, click the control to select it, then drag the control to the correct position.
b. To resize the control, click the control to select it, drag one of the eight sizing handles until the control is
properly sized, then release the mouse button.

Changing Object Properties


When you design the user interface of your VB.NET applications, you must set the properties for the objects you
create. This window displays the properties of a form:
Continuing Your First Visual Basic Project
Step 1: Open Your Project
Step 2: Drag the Appropriate Controls on the Form and Set the Properties
Step 3: Run Your Project
Press “F5” to run your application. Make sure to save this project for the succeeding lessons.

Working with Variables and Data Types


Declaring Variables
In Visual Basic .NET, you use variables to store values that can change when your application is running.
The Dim (short for “dimension”) statement is used to declare variables. You can specify the name of a variable
and type of storage in the Dim statement.
The following code snippet illustrates the declaration for different types of variables:
Data Types
The data type of a programming element refers to the kind of data it can hold and how data is stored. An
application needs to store the data first entered by the user before it can display the result. The table lists some data
types provided by Visual Basic .NET to store various types of data that you can choose from.

Access Modifiers
When using variables, you also have to consider their accessibility to all areas of your code that refer to them. In
some cases, you might need to restrict user access to some of the variables that you have created. For this purpose, you
can use the different access modifiers available in VB.NET:
This code shows you how to declare a variable using some of the access modifiers mentioned:

Assigning Values to Variables


After you declare a variable, you can assign a value to it by using the assignment operator (=), as shown here:

You can also assign a value to a variable when you declare it, as shown here:

The “=” symbol is commonly used as the assignment operator symbol for most programming languages.
However, this can sometimes cause people to confuse it with the equivalence operator in relational expressions. In an
assignment statement, the expression on the right-hand side is first evaluated and then its value is assigned to the
variable on the left.
Working with Operators and Making Choices
Arithmetic Operators
Arithmetic operators are symbols used to perform arithmetic operations on variables. Below are some of the
commonly used arithmetic operators:

Comparison Operators
Comparison operators are used to compare two values and perform an action based on the result of the comparison.
Some commonly used comparison operators are listed here:
Logical Operators
To better understand how they work, you must learn how to use the truth table:

AND OPERATION OR OPERATION

Logical operators are used to evaluate expressions and return to a Boolean value. Some commonly used logical
operations:

Concatenation Operators
Concatenation operators are used to join two expressions. Some commonly used concatenation operators:

You might also like