subscribe: Posts | Comments



I. Tables
I.1. Definition

A table is in the case of a graph, the statement of screen space in the form of graphic location.
I explain, if we take a configuration screen graphic 800×600, it means that the screen includes 800 pixels on a line, and 600 pixels on a column. A pixel representing a point on the screen.

Ex: A pixel = this [. ]
Each part of the screen being represented, if we want to animate a chart, we have to declare in the program, ie to Visual Basic, the configuration screen that we will use.
In the one application that I have already developed ( "Patman"), I decided that the table would include 456 cases, how I managed to find this figure?
I draw several graphic elements to represent the interface work, for example, I can reproduce one of these elements, (he is), it measures 23×23 pixels. To build the GUI screen space in which I had, I calculated that I could put it in the length of the screen 19 features, and the width of the screen 24 elements. The calculation is simple 19 that multiplies 24 equals 456.
These figures may change depending on the configuration screen and dimensions of what you have drawn.

I.2. How will we declare this table?
Sunday <selected tableau> <list of parametres> As <type of tableau>

Usually we declare for example:
Mon_tableau Sunday (1 to 12) As Integer

In the case of the example cited above, we declarerons our table with the following instructions:
* Global Const NB_CASES = 456
* Global Const NB_LIGNES = 19
* Global Const NB_COLONNES = 24
If we refer to the previous explanations, we conclude that we have to declare a table that includes 19 lines, 24 columns, 456 boxes, which are constants, therefore, who have fixed values and are reported globally in all the programme, therefore to be taken into account by all worksheets if there are several.

We declarerons this information in a module that we call for example: "Global.bas"

II. Assignments treatment or conditional
We will finish these exercises by the treatment conditional:
Let the "IF Then Else":
<nom_de_la_variable> = <function> <nom_de_la_variable> <value> <operation>

If (If) include a condition So (Then) give instructions to apply the requirement if the condition can be executed, Else (new condition) to give new instructions to execute a new condition if the first does not executed. End If End treatment conditional.

If <condition> Then <instruction> Else <instruction>
If table (row, column) = Then Patman
'Translation = if the table represented by the rows and columns is equal to patman (object) then read the following instructions </ li>
Patman line = Patman 'line patman becomes patman (object)
Patman column = Patman 'column patman becomes patman (object) <a name="contents"> </ li>
'Instructions (if the first condition is not met)
'Give new instructions </ lie>
End If
Take note warning that if the condition is not met, the pointer Visual Basic ignore instructions and jump to the next instruction.

We can also use the term Else If (or good) which allows you to use another instruction if one used previously is not executed!

You find that before the word Instruction, I put an apostrophe '; indeed Visual Basic considers that any writing preceded by an apostrophe is not taken into account by the compiler.
So all lines of comments are preceded by an apostrophe and serve the developer to explain the form and the idea of his text.
I advise you to save as much feedback as possible.

HTML clipboard

III. The meter loop
III-1. What is a loop?

We can compare a loop to a point that circulates in a circle and turning endlessly.
It may add a counter that increment (ajouter1) the number of laps each time that it will pass in front of square one.

You can also get him out of the loop after a certain number of laps.
1 – Starting Point
2 – execute a turn
3 – control the number of laps
4 – If the counter value is equal to or greater than 3, then the fate of the loop
5 – If the counter value is below à3
6 – Add 1 to the value of meter and go back to square one

III-2. Let the loop "For Next …"
For <computer> = <debut> <trailing> To Step <pas>
<bloc distractions>
For Exit
<bloc distractions>
Next <computer>

Example of use: We want to recognise the months of the year in a loop, write:
For Month = 12 To 1 Step -1
Total = + Total Amount (Month)
Next Month
In this example we decreases (Counting negative) of 12 to 1 variable Step indicates no decrement, and in this case we want decrement of 1 (months) if we had wanted to make calculations based on a quarter we would have been like " not worth "the figure 3 (Step – 3)

The line runs the education program and asked the Next is the variable end of proceedings.
If you want to better understand the operation of counting with buckles, click on the link that opens the file [EXERCICE1]

IV. The main arithmetic operators and comparison
IV.1. The arithmetic operators

Operator Meaning Example
Adds two numbers a + b
-  Subtract two numbers or makes a negative number a-b or -92
* Multiply two numbers a * b
/ Divides two numbers a / b

IV.2. The comparison operators

Operator Meaning Example
< Less than a <b (a smaller b)
<= Less than or equal to a <= b
> Superior  a> b
> = Greater than or equal a> = b
 = Egal a= b
<> Unlike a <> b
& Returns a string which is the concatenation of two other Hello & Gentlemen, returns "Hello gentlemen"