Monday, June 13, 2011

Visual Basic

HTML server controls are of two slightly different types. The HTML elements most commonly used in forms are available as individual HTML server controls, such as HtmlInputText, HtmlInputButton, HtmlTable, and so on. These HTML server controls expose their own, control-specific properties that map directly to HTML attributes. However, any HTML element can be converted to a control. In that case, the element becomes an HtmlGenericControl with base class properties such as TagName, Visible, and InnerHTML.

To set properties of HTML server controls
Get or set the property name as you would with any object. All properties are either strings or integers. The following examples illustrate this:
' Visual Basic
myAnchor.Href = "http://www.microsoft.com"
Text1.MaxLength = 20
Text1.Value = string.Format("{0:$###}", TotalCost)
Span1.InnerHTML = "You must enter a value for Email Address."

// C#
myAnchor.HRef = "http://www.microsoft.com";
Text1.MaxLength = 20;
Text1.Value = string.Format("{0:$####}", TotalCost);
Span1.InnerHtml = "You must enter a value for Email Address.";

All HTML server controls also support an Attributes collection, which gives you direct access to all the control's attributes. This is particularly useful for working with attributes that are not exposed as individual properties.

To work with control attributes directly
Use the properties and methods of a control's Attributes collection, such as Add, Remove, Clear, and Count. The Keys property returns a collection containing the names of all the attributes in the control. The following examples show various ways to use the Attributes collection:
' Visual Basic
' Adds new attribute.
Text1.Attributes.Add("bgcolor", "red")
' Removes one attribute.
Text1.Attributes.Remove("maxlength")
' Removes all attributes, clearing all properties.
Text1.Attributes.Clear()
' Creates comma-delimited list of defined attributes
Dim strTemp As String = ""
Dim key As String
For Each key In Text1.Attributes.Keys
strTemp &= Text1.Attributes(key) & ", "
Next

// C#
// Adds a new attribute.
Text1.Attributes.Add("bgcolor","red");
// Removes one attribute.
Text1.Attributes.Remove("maxlength");
// Removes all attributes, clearing all properties.
Text1.Attributes.Clear();
// Creates comma-delimited list of defined attributes
string strTemp = "";
foreach (string key in Text1.Attributes.Keys)
{
strTemp += Text1.Attributes[key] + ", ";
}
READ MORE - Visual Basic

Monday, June 6, 2011

procedure is a block of program code designed to solve common problems

procedure is a block of program code designed to solve common problems. Suppose the pascal programming language known as Writeln procedures, clrscr, textbackground, textcolor, readln, etc.. The invitation to these procedures vary from one procedure to another procedure. Suppose that function clrscr procedure to remove all the writing on the screen and position the cursor at X = 0 and Y = 0. Clrscr in the calling procedure does not require parameters; procedure Writeln / write function to print the output (output) to the screen. Procedure Writeln / write can be called with or without include parameters include parameters. For example, instructed the translator (compiler) Pascal to move the cursor down one line (Score Increase Y) and X remained in position 0 as shown in the following code:

begin
Writeln;
end.

In the above code was called Writeln procedures not followed by parameters. Pascal understand that if the Writeln procedure call without parameters then position the cursor on the monitor changes the cursor back to position X = 0 (Carriage Return) and the Y position plus One - Down The Line (Line Feed).

Another example we could send Writeln procedure to print a multiplication 10 * 10:

begin
Writeln (10 * 10);
end.

The code above can be explained that we call the Writeln procedure by sending a parameter multiplying 10 * 10. Because the Writeln procedure is a procedure that has been ready to use (built-in procedure) or have been defined by pascal eat the detail of the instructions in the Writeln procedure we do not know for sure.

We can also tell Writeln command to print a string of characters (string) "Respati Yogyakarta":

begin
Writeln ('Respati Yogyakarta');
end.

Or a combination of value and konstanta as follows:
begin
Writeln (10 * 10, 'Respati Yogyakarta');
end.

Flexibility Writeln procedure would be very helpful in giving commands to the computer.

User Defined Procedures
Pascal allows programmers to create their own procedures (user defined procedure). The procedure (syntax) the declaration made by the user procedure is:

namaprosedur procedure ([par1, par2, par3, ... parn]);
{Variables declarations}
{Declarations} procedure
{Functions declarations}
{Constants declarations}
{Declaration} label

begin

end;

Dikelarasikan procedures can then be called from the main program or from the procedure itself or other procedures.

The following will be a procedure to print the address Unriyo Yogyakarta:

CetakAlamat Program;
uses crt;
procedure Address ();
begin
Writeln ('University Respati Yogyakarta');
Writeln ('Jln.Laksda Adisucipto Km.6, 3 Depok, Sleman, Yogyakarta');
end;

Begin
clrscr;
Address} {Calling Procedure
Address ();
End.

Procedure Berparameter
Procedures are given specific tasks to take parameters as needed. Suppose there are desirable procedure to print numbers 1 to N. Here the N value is uncertain, can be 10, 20, 100. For this procedure call when we send the value of N and further process the printing procedure numbers 1 to N.


Print-Program;
Uses Crt;

Procedure CetakAngka1Sd (N: Byte);
Var
I: Byte;} {Declaration of Local
Begin
For I: = 1 To N Do
Writeln (I);
End;

{Main Program}
Begin
{Clear the screen}
clrscr;
Print a Procedure Call {20} s.d
CetakAngka1SD (20);
{Procedure Call Again Print Number 1 s.d 100}
CetakAngka1SD (100);
Readln; {Wait Pressing Enter key}
End.


Parameter Value and Reference Parameters
In general, the parameters passed to the procedure are the parameter value means the parameter value will not change after the procedure call. When the desired parameter value changes after calling the procedure, the parameter is called a reference parameter.

Create a procedure to calculate the number of runs the following:
1 / 1 +1 / 2 +1 / 3 + ... 1 / N
Desired number N is uncertain and at once the sum looks after the procedure call. Thus it takes 2 (two) parameters: N (parameter value) and amount (reference parameter).


Jumlah_Deret Program;
Uses Crt;

Procedure Number (N: Byte; Var Amount: Real);
Var
I: Byte;
Begin
Total: = 0;
For I: = 1 To N Do
Total: = Total + 1 / I
End;

Var
Cacah_Data: Byte;
Results: Real;
Begin
clrscr;
Cacah_Data: = 10;
{Procedure Call}
Total (Cacah_Data, Result);
Writeln ('Number of Series', Result: 8:2);
Readln;
End.

Variable Scope
The scope variables (variables scope) describes the accessibility of these variables. In Pascal there are 2 (two) types of scope that is global and local scope. Global scope indicates that the variable will be recognized throughout the program code. Local scope indicates that the variable is only known place declared.

Suppose there are programs such as the following:

Var
IGlobal: Byte;

Procedure LokalSatu;
Var
ILokal1: Byte;
Begin
ILokal1: = 10;
Writeln (ILokal1, IGlobal);
End;

Procedure LokalDua;
Var
ILokal2: Byte;
Begin
ILokal2: = 20;
Writeln (ILokal2, IGlobal);
End;

{Main Program}
Begin
IGlobal: = 10;
Local;
End.

In the above code IGlobal variable will be recognized throughout the source code (both in the Main Program, LokalSatu Procedure, Procedure LokalDua). While the variable will only be known in ILokal1 LokalSatu procedure. Likewise ILokal2 variables will only be known in LokalDua procedure.

We note again the following program code:

Lingkup_Lingkup Program;
Var
I: Byte;
Outlying Procedure;
Var
ITerluar: Byte;
Deepest Procedure;
Var
ITerdalam: Byte;
Begin
ITerdalam: = 20;
Writeln (I, ITerluar, ITerdalam);
End;
Begin
ITerluar: = 10;
Outlying} {Call Procedure
End;

{Main Program}
Begin
I: = 5;
Outlying;
End.

In the code above first global nature means it will be recognized in the main program, procedures for the outer and inner procedure. ITerluar variables will be global in that procedure so that the variable will be recognized procedures declared in the procedure. However ITerluar variables will not be recognized by the Main Program. ITerdalam variables will only be recognized by Deepest Procedure.

Recursive Procedure
The procedure that calls itself is called as recursive procedures. Suppose there is code like the following:

Procedure Print;
Begin
Writeln ('Respati');
{Procedure Call} Himself
Print;
End;

{Main Program}
Begin
{Procedure Call}
Print;
End.

The above source code can be explained as follows:
1. Start
2. Procedure Call Print
3. Print string 'Respati'
4. Procedure Call Print
5. Print string 'Respati'
6. Procedure Call Print
7. Print string 'Respati'
8. ff

Summons against itself will still be conducted Print procedure because there is no statement to stop calling. This calling will continue ongoing (continues call).
To overcome this problem it is necessary to make a statement that limits the procedure call. Suppose the above program code we change something like this:


Var
I: Byte;
Procedure Print;
Begin
IF (I <= 5) Then begin Writeln ('Respati'); {Procedure Call} Himself Print; I: = I +1; end; End; {Main Program} Begin I: = 1; {Procedure Call} Print; End. In the code above procedure will only be invoked Print 5x as much as stated in condition IF (I <= 5). If I> 5 then print the procedure will not be called again. Generally determined a condition that lay on the procedure call itself.

Parameter array
Array parameters can be passed to the procedure with little difference from the parameters of conventional type (byte, word, integer, real).

Jumlah_Data Program;
Const
N = 100;
Type
Data: Array [1 .. N] Of Single;
Var
Adata: Data;

Procedure Number (DataA: Data, Count: Byte) '
Begin
For I: = 1 To N Do
Jlh: = Jlh + DataA [I];
Writeln ('Number of Data Is', Jlh: 12:0);
End;

{Main Program}
Begin
{Enter data}
ADATA [1]: = 70;
ADATA [1]: = 65.5;
ADATA [1]: = 89;
ADATA [1]: = 77;
ADATA [1]: = 64;
ADATA [1]: = 78.5;
{Call Procedure Number of Data}
Total (Adata, 6);
Readln;
End.

Exercise Procedure
Known weight data Prodi student information system as below:
65,78,58,60,63,56,65,69,77
Make procedures for:
1.menginputkan N Fruit data
2.menghitung number, average weight and standard deviation
3.mengurutkan data in ascending (ascending)
4.mengurutkan data in descending order (descending)
5.melihat contents array

To resolve these cases will be made in the form pilihahan menu making it easier in the use of the program.
Menu Options
1. Input Data
2. Determine Total, Average and Standard Deviation
3. Sort Data In Ascending
4. Sort Data By Descending
5. Display Array Contents
Your choice [1 .. 5]:


Statistics Program;
Uses Crt;
Const
N = 100;

{Weight} Input Procedure Declaration
Procedure Input_Berat (Berat_Mhs: Weight: N: Byte);
Var
I: Byte;
Begin
For I: = 1 To N Do
Begin
write ('Enter The Weight', I ,':'); readln (Berat_Mhs [I]);
End;
End;

{Main Program}
Var
Repeat: Boolean;
Pills: ShortInt;
Begin
Repeat: = True;
While (Repeat) Do
Begin
clrscr;
gotoxy (25.1), write ('U U M E N T A M A');
gotoxy (25.2); write ('---------');
gotoxy (25.3), write ('1. Input Data ');
gotoxy (25.4), write ('2. Determine the Number of, Average, Standard Deviation ');
gotoxy (25.5), write ('3. Heavy Sort Descending ');
gotoxy (25.6), write ('4. Heavy Sort Ascending ');
gotoxy (25.7), write ('5. Show Array ");
gotoxy (25.8), write ('0. Done ');
pill: =- 1;
while (pills <0) or (pill> 5) do
begin
gotoxy (25.9), write ('Your Choice [0 .. 5]:'); readln (pills);
end;
Test {More}
Case (Pil) Of
1: Begin Weight} {Input Data

End;
2: Begin {Set Total, Average and Standard Deviation}

End;
3: Begin {} Ascending Sort By

End;
4: Begin {} Sort By Descending

End;
5: Begin Array} {Shown Contents

End;
0: Begin {End Program}

End;
End;} {End of Case
End; {End While}
End. {End Program}
READ MORE - procedure is a block of program code designed to solve common problems

Pascal triangle

Pascal triangle shape can be arranged as below:
1
121
1331
14641
15101051
................

To facilitate understanding of each element of the above can we put in the matrix as follows:
- Number 1 in row 1 column 1
- Number 1 in row 2 column 1, number 2 in row 2 column 2, number 1 row 2 column 3
- Number 1 in row 3 column 1, number 3 in row 3 column 2, number 3 in row 3 column 3, number 1 in row three column 4
and so on

We note that each line has a lot of counting elements such as the following:
First-line there is 1 element
The second-row there are 3 elements
The third-row there are 4 elements
Fourth-line there are 5 elements
-And so on
The second line, third, fourth and so on plus-plus element two.

Suppose there is a matrix A (N, M), then these values ​​can be entered as follows:
A (1,1) = 1
A (2,1) = 1
A (2,2) = 2
A (2,3) = 1
A (3,1) = 1
A (3,2) = 3
A (3.3) = 3
A (3,4) = 1
and so on

To facilitate workmanship we will initialize 2 pieces of array elements
About the way the process as follows:
0. Start
1. Specify many levels, say N, Determine matrix A (10.10)
Define A (1,1) = 1, A (1,2) = 1
2. Print row and first column
3. Starting first from 2 to N
4. Print 1
5. Ranging from 2 to I
Determine the next value
Value = A (I-1, J-1) + A (I-1, J)
Value = matrix current line minus one, minus one column current + current reduced matrix row one, column today.
Print Values
6. Repeat to 5
7. Print 1
8. Down Line
9. Repeat to 3
10. completed
Private Sub Form_Activate ()
Dim A (10.10) As Byte
A (1,1) = 1 'Initialize
A (1,2) = 1 'Initialize
print A (1,1) 'print the first line
For I = 2 To 10 Step 1 'value 10 is considered a level up to 10
print "1"
For J = 2 To First Step 1
Value = A (I-1, J-1) + A (I-1, J)
print value;
Next J
Print "1";
Print 'Down Line
Next I
End Sub
READ MORE - Pascal triangle

The data type is a limit value that can be saved

The data type is a limit value that can be saved. In MS-Access there are different kinds of data types include:
- Byte
- Integer
- Text
- Date / Time
- Number
Suppose you want to keep track student's name. Names of the students to like "Rita", "Ahmad Dahlan", "Betra Aginta Ginter", and so forth. The name is composed of the characters. To accommodate the character data of MS-Access provides a data type text. Another example suppose you want to keep the weight of a student data. Weight data are generally stored in the fractions. For example, Ani weight 45.5 kg. To accommodate the data is numeric, MS-Access provides a data type Number.
READ MORE - The data type is a limit value that can be saved

Arithmetic Statement

Arithmetic Statement

Unknown 3 (three) pieces of numbers A, B and C. Make a visual basic program to solve the following arithmetic equation:
P = A + B
Q = B-A
X = A + BC
R = (A + B) * C
S = (A + B) * (A-C)
M = A Mod 2
N = B-A + C ^ 2

- user interface program

- Implementation

Dim A, B, C As Single 'Global Declaration

Private Sub cmdHitungM_Click ()
Dim B As Single
A = Val (txtA.Text)
B = Val (txtB.Text)
M = A Mod 2
txtM.Text = Str (M)
End Sub

Private Sub cmdHitungN_Click ()
Dim N As Single
A = Val (txtA.Text)
B = Val (txtB.Text)
C = Val (txtC.Text)
N = B - A + C ^ 2
txtN.Text = Str (N)
End Sub

Private Sub cmdHitungP_Click ()
Dim P As Single
A = Val (txtA.Text)
B = Val (txtB.Text)
P = A + B
txtP.Text = Str (P)

End Sub

Private Sub cmdHitungQ_Click ()
Dim Q As Single
A = Val (txtA.Text)
B = Val (txtB.Text)
Q = B - A
txtQ.Text = Str (Q)
End Sub

Private Sub cmdHitungR_Click ()
Dim R As Single
A = Val (txtA.Text)
B = Val (txtB.Text)
C = Val (txtC.Text)
R = (A + B) * C
txtR.Text = Str (R)
End Sub

Private Sub cmdHitungS_Click ()
Dim S As Single
A = Val (txtA.Text)
B = Val (txtB.Text)
C = Val (txtC.Text)
S = (A + B) * (A - C)
txtS.Text = Str (S)
End Sub

Private Sub cmdHitungX_Click ()
Dim X As Single
A = Val (txtA.Text)
B = Val (txtB.Text)
X = A + B * C
txtX.Text = Str (X)
End Sub

Private Sub cmdTutup_Click ()
End
End Sub

- Running

Analysis
 Statement P = A + B, can be understood by Visual Basic because the procedure of writing (syntax) is correct. This expression can be described also as follows:
 P is the operand
 = Is the operator
 A is the operand
 + Is an operator
 B is the operand
 So from the above statement there are 3 pieces of operands.

Operands in Visual Basic can be identifiers, functions or constants. The statement Z = 5 + 5 also can be recognized by visual basic. Number 5 in the statement is an operand whose value is 5. Statement
 Z = rank (5) + A also can be understood by Visual Basic when the definition of rank function with the parameters already defined.

Each statement of Visual Basic can be divided into 2 (two) groups:
 -Groups of the left (left operand) and
 Right-group (right) operand)
 between groups separated by an equal sign (=)

On the left of the group must be identification, whether variable or constant identifier and not the value of variables, constants. Visual Basic does not recognize this writing the following statement:
 5 = A + B 'false statement
 5 + 5 = A 'statement wrong
 "Santi" = A 'statement wrong
 Rank (5) = 10 'false statement

The statement will be true when written like this:
 Z = A + B
 A = 5 + 5
 A = "santi" 'set of characters (string) given to the identification A
 Z = rank (5) 'statement called the rank function with 5 parameters

The order of execution in both groups will start from the second group. Further progress in the second group will be tailored to the degree of the operator (see note below for details). Suppose there is a statement:
 Z = A + C - B
 then the process will begin the process of:
 1. A + B, ie X
 2. X - B, ie R
 3. R was given to Z

Notes
 -Of particular interest in the formation of an arithmetic expression is a sequence of execution of each operator.
 -The order processing service will start from the left.
 -If found, the bracketed expressions in parentheses will be done the first time
 Rank-Operator (^) is the operator that has the highest degree of workmanship. The execution of the operator ^ more precedence than the operator /, *, Mod, + or -.
 -Operator for (/), times (*) and Mod (remainder of) have the same degree of craftsmanship and workmanship higher priority than the operator plus (+) and minus (-).
 -The operator plus (+) and minus (-) have the same degree of workmanship.
READ MORE - Arithmetic Statement

Arithmetic operations

Arithmetic operations

Arithmetic operation is an operation involving arithmetic operators. Arithmetic Operators in Visual Basic is:
- plus (+)
- minus (-)
- times (*)
- for (/)
- rank (^)
- residual for (mod)

Arithmetic operators generally operate on two operands. For example the expression 2 + 2, means:
2 is the first operand
Arithmetic operator + is added
2 is the second operator.

But in some respects, especially operators + and less operate on one operand, such as giving the value of +5 (positive 5) or -5 (negative five).

In visual basic arithmetic operators workmanship has set the degree of workmanship as follows:

Operator Degrees
^ 1
* / Mod 2
+ - 3

operators who have the same degree will be done starting from the left.
For example there is the statement:
A = 2 + 2-5
seen that there are two of the arithmetic operators + and -. It was decided that the operators + and - have the same degree of craftsmanship so that the operator of the most left will done first. Thus the order of execution of the statement are:
1. 2 + 2 provides the results of 4
2. 4-5 give the results -1
3. -1 was given to a variable A

Suppose there are statements like the following:
A = 2 + 5 * 10, then the process sequence is
1. 5 * 10 = 50
2. 2 + 50 = 52
3. 52 were given to A

We consider the operator * is done in advance rather than operator +. How about if we change the order of workmanship want where desired operator + higher degree of workmanship of the operator *. To do this on a operator operators + plus open parenthesis and close parenthesis so that the form of a statement becomes:
A = (2 +5) * 10, then the order of the process becomes:
1. 2 + 5 = 7
2. 7 * 10 = 70
3. 70 were given to A

If there are parentheses within parentheses, the innermost parentheses to be done first. For example there is a statement as follows:
A = 7 * ((2 +5) * 10), then the sequence of the process becomes:
1. 2 + 5 = 7
2. 7 * 10 = 70
3. 7 * 70 = 490
4. 490 were given to A

Suppose there is a statement as follows:
A = (2 + 5) * 10-15 + 7 ^ 2, then the order of execution of the statement are:
1. 2 + 5 = 7
2. 7 ^ 2 = 49
3. 7 * 10 = 70
4. 70-15 = 55
5. 55 + 49 = 104
6. The value 104 was given to A
READ MORE - Arithmetic operations

Array is a single variable that can hold multiple values

Array is a single variable that can hold multiple values​​. Each value stored in a different array index.

Arrays are typically used to collect data that can be prepared based on certain numbers. For example, to keep high all the students of Information Systems Studies Program, Faculty of Science and Technology, University of Respati Yogakarta will further simplify its management when stored in the array. So the declaration of Array for high-data can be done as follows:

Dim Appeal (1000) As Single

High (1) = 165.5

High (2) = 175.5

High (3) = 180

ff

You note the index (1), (2), (3) at the end of the High Variable name. The index is a differentiator from each container value. In the declaration Array High (1000) means that the highest index is 1000. When you make statements like the following:

High (1001) then the interpreter will display the details wrong because of your height array variable declaration to limit the index to 1000.
READ MORE - Array is a single variable that can hold multiple values
 
THANK YOU FOR VISITING