Sie sind auf Seite 1von 4

Describe the features of a programming language

Variables (naming conventions)

Variables are the area that the program stores the data that is inputted into the
program and they can be also used as a temporary storage area for data needed
during processing and the data output by a program would come from program
variables as well. When the program ends all the contents of variables are lost.

There are two main attributes of variables, one of which is a name, find the
variable inside of the program. The other attribute is a data type and what this is
that whatever variable the data can store the data type defines that data.

Variables are declared at the beginning of the program. Here is an example of a


variable in visual basic.

Dim PassUnitPoints As Integer


Dim MeritUnitPoints As Integer
Dim DestinctionUnitPoints As Integer There are some dim
Dim GradeBoundaryPoints As Integer variables I declared in
Dim UCASPass As Integer my ucas calculator
Dim UCASMerit As Integer
Dim UCASDestinction As Integer program.
Dim UnitCounter As Integer

Variables (Global and Local Variables)

Global and local variables run a very important role in a program if you don’t
declare your variables at the beginning of the program the program will come up
with a lot of errors in the code but when u declare the variables then the
program understands the variables you have declared.

Global variables are used when you need the value outside of the range. Local
variables stop once the function that created them has ended; they are usually
needed in one part of the code.

Dim PassUnitPoints As Integer


Dim MeritUnitPoints As Integer
Dim DestinctionUnitPoints As Integer
Dim GradeBoundaryPoints As Integer Here are some global
Dim UCASPass As Integer
and local variables.
Dim UCASMerit As Integer
Dim UCASDestinction As Integer
Dim UnitCounter As Integer
Loops (pre-check, post-check)

Loops in a program are a set of instructions that need to be repeated a certain number of times or
when a criterion is met.

Fixed loops – they execute a fixed number of times


Private Sub CMDFOR_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles CMDFOR.Click
Dim A As Integer
A = 1
For A = 1 To 4
MsgBox(4)
Next
Conditional loop – they execute repeatedly until some condition is met

Dim B As Integer

B = 1
Do Until B = 4
MsgBox(B)
B = B + 1
Loop

Conditional statements

Conditional statements allow a choice to be made as to which set of statements


are to be carried out next. In most programming languages they usually have
the ‘If’ statements. There are also ‘ElseIf’ statements.

Conditional statement allows a choice to be made i.e. if to deal the next card or
not. “If” statement is usually used and also “elseif” statement.

If dealCounter = 1 Then
LblCard1.Visible = True
CmdDealer.Text = "Deal Card 2"
PontoonScore = PontoonScore + score

LblCard1.Text = Score
lblScore.Text = PontoonScore
ElseIf dealCounter = 2 Then
LblCard2.Visible = True
CmdDealer.Text = "Hit Me!"
PontoonScore = PontoonScore + score

LblCard2.Text = Score

LblCard5.Text = Score
lblScore.Text = Score & "Five Card Trick"
CmdDealer.Enabled = False
End If
Logical operators

Conditional statements are used in If statements and in Do Until loops to


combine more than one condition.

E.g.

Operat Meaning
or

> This arrow means greater than

< This arrow means less than

= This means equal to

>= This means greater than or equal to

<= This means less than or equal to

<> These to arrows mean that it’s not equal to

AND produces true if both sides are true

OR Produces true if either side is true

NOT Produces the opposite result


Assignment statement

Assignment statement is when you can assign to certain variables; they can also be used by using
mathematical operators such as plus and minus. When you combine two operators then order of
execution is based on the actual order.

Operator Meaning Example

^ To the power of 12^ 2 = 24

* Multiply 5* 7 = 35

/ Division 48 / 10 = 4.8

Mod Remainder 5 mod 2 = 1

+ Add 52 + 55 = 107

- subtract 120 – 20 = 100

Input and output statements

Input and output in VB are usually done by a control (textbox, button etc) that
are placed on the form for the user to use.

For e.g. a user clicks a button on VB, the subroutine collects values that the user
has clicked the button and displays results.

Das könnte Ihnen auch gefallen