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

Converting Decimal to Hexadecimal Visual Basic

Converting Decimal to Hexadecimal Visual Basic

Decimal number that is composed of 10 digits: 0,1,2,3,4,5,6,7,8,9, while composed of 16 hexadecimal digits are: 0,1,2,3,4,5,6 , 7,8,9, A, B, C, D, E, F. We note that the first 10-digit hexadecimal number is a decimal number. It could be argued that the decimal number is a subset of hexadecimal numbers.
From the programming side of the decimal numbers apply in general, while hexadecimal numbers are generally used to shorten the writing of a decimal or binary numbers. Implementation hexadecimal pengelamatan much visible in the computer memory.

Hexadecimal Decimal
0 0
1 1
2 2
3 3
4 4
5 5
6 6
7 7
8 8
9 9
10 A
11 B
12 C
13 D
14 E
15 F

To perform the conversion of decimal numbers to hexadecimal is to share with the decimal number 16 as a hexadecimal base. For example, suppose there is a decimal number 9 then the number heksadesimalnya are:
9: 16 = 0 remainder 9
then the hexadecimal number is 9

Suppose there is a decimal number 25 then the number heksadesimalnya are:
25: 16 = 1 remainder 9
1: 16 = 0 remainder 1
so the number is 19 heksadeimalnya

Algorithm:
0. Start
1. Determine the decimal number, eg N
2. As long as N> 16 do
Results = N Div 16
Time = N Mod 16
N = Result
Hex = Hex + Time
3. Repeat to 2
4. Print Hex
5. Completed

Implementation
Private Sub Form_Activate ()
Dim N, Results, Time As Byte
Hex As String Dim
Hex = ""
While N> 16
Results = N Div 16
Time = N Mod 16
N = Result
Hex = Hex + Time
Wend
Print Hex
End Sub
READ MORE - Converting Decimal to Hexadecimal Visual Basic

Decimal to Binary Conversion Visual Basic

Decimal to Binary Conversion Visual Basic

Decimal digits arranged over 10 pieces ie 0,1,2,3,4,5,6,7,8,9. Because the constituent digits as much as 10 it is called a base 10 number system. How do I get the base 10 number system is converted into binary systems based on 2 (0 da 1)? This can be done by performing division of decimal numbers with 2 to decimal numbers are smaller than 2. Binary number is the remainder of the division. Suppose there is decimal 10, binary numbers are:
10: 2 = 5 remainder 0
5: 2 = 2 remainder 1
2: 2 = 1 remainder 0
1: 2 = 0 remainder 1

thus obtained binary number is 1010.

Suppose again there are 65 decimal then the conversion to binary is:
65: 2 = 32 remainder 1
32: 2 = 16 remainder 0
16: 2 = 8 remainder 0
8: 2 = 4 remainder 0
4: 2 = 2 remainder 0
2: 2 = 1 remainder 0
1: 2 = 0 remainder 1

thus obtained binary 1000001

We note that every decimal numbers divided by 2. Time sharing is a binary digit. The division is done continuously until the quotient is smaller than 2. Binary number composed of the rest of the division of the latter.

Algorithm
0.mulai
1.Tentukan decimal numbers, eg: N as the numerator
2. Determine the number of denominators, eg, X; Set Binary = ""
3. Repeat For N> X do
Results = N Div X
Time = N Mod 2
N = Result
Binary = Binary + Time
4. Back to 3
5. Binary Print
6. Completed

Implementation
Private Sub Form_Activate ()
Dim N, X, Left, I, Length As Byte
Dim Binary As String
N = 65 'Decimal Numbers
Binary = ""
While N> X
Results = N Div X
Time = N Mod X
Binary = Binary + Time
N = Result
Wend
Binary Print
End Sub
READ MORE - Decimal to Binary Conversion Visual Basic

Binary To Decimal Conversions

Binary To Decimal Conversions

Binary number composed of 2 digits ie 0 and 1. In terms of computer programming, the binary number has a significant role because of all the binary code will be represented in binary form. For example, A has the code decimal number 65 in iplementasi the engine will be translated into the binary number 01000001. Code composed of a series of 0 and 1 would be difficult to understand. For that sometimes we change the binary code into decimal.
Suppose there is a binary code 01000001 then each digit can be represented in decimal as follows:
128 64 32 16 8 4 2 1

0 1 0 0 0 0 0 1

Any number 1 so we add the decimal representation is obtained:
64 + 1 = 65

Representations were obtained through the formula as follows:
1 X 2 ^ 0 = 1
1 X 2 ^ 1 = 2
1 X 2 ^ 2 = 4
1 X 2 ^ 3 = 8
1 X 2 ^ 4 = 16
1 X 2 ^ 5 = 32
1 X 2 ^ 6 = 64
1 X 2 ^ 7 = 128

Algorithm
0.Mulai
1.Tentukan binary, Bin
Bil long 2.Tentukan eg N
3.Tentukan Result = 0
4. Repeat I = 0 To N-1 Step 1
Result = Result + Num (I) * 2 ^ I
5. Repeat I
6. Print Results
7. Completed

Implementation
Private Sub Form_Activate ()
Dim I, N, Result As Byte
Bin = "01000001"
N = Len (Bin)
Result = 0
For I = 0 To N-1 Step 1
Result = Result + Num (I) * 2 ^ I
Next I
Print Bin; "is:"; Results
End Sub
READ MORE - Binary To Decimal Conversions

Determining Prime Numbers Visual Basic

Determining Prime Numbers Visual Basic

Prime numbers are numbers which only numbers divisible by 1 and itself. But there are exceptions that number 2 is prime. The dereten primes are:
2,3,5,7,11,13,17, ...

For example number 3 is prime because 3 is only divisible by 1 and the number itself.
Denominator: the numerator Result Time
3: 1 3 0
3: 3 1 0

Number 3 is only divisible by 1 and 3

Examples of non-prime number is 4
Denominator: the numerator Result Time
4: 1 4 0
4: 2 2 0
4: 4 1 0

4 Numbers divisible by 1,2 and 4.

Algorithm
0. Start
1. Specify a number, eg N
2. Determine Count Prima, eg CPrima = 0
3. I repeat from 1 s.d N
Test Is N Mod I = 0
If Yes then Add CPrima = CPrima + 1
Test Is CPrima> 2
If Yes Go to Step 4
4. Repeat to 3
5. Test If CPrima2 So Not Prima N
6. Completed
Private Sub Form_Activate ()
Dim N, I, CPrima As Byte
N = 7 'number to be tested
CPrima = 0 'Count Zero Distribution
For I = 1 To N Step 1
IF (N Mod I = 0) Then
CPrima = CPrima + 1
IF CPrima> 2 Then Exit For
End IF
Next I
IF CPrima <= 2 Then
Print N; "Prime Numbers"
Else
Print N; "Not Numbers Prima"
End Sub
READ MORE - Determining Prime Numbers Visual Basic

Salary Calculation Visual Basic

Salary Calculation Visual Basic

Design interface program to calculate the net salary of an employee with some of the following provisions:
-an employee has a NIM attribute, name, jenkel, marital status, number of children, class, position.

Devise a program interface as shown below:


When pressed F5 (to run the VB program) then
a. empty all textbox, option radion and combo box
b. disable all the textbox, cmbproses, cmbbatal
At the moment we press the F5 key, then the translator (compiler), Visual Basic first working Form_Load event. To the right lay the source code gives the initial value of each variable used in both textbox, option radion, combobox and command.

Private Sub Form_Load ()
'Clear the textbox
txtNip.Text = ""
txtNama.Text = ""
txtJAnak.Text = ""
txtGPokok.Text = ""
txtTIstri.Text = ""
txtTAnak.Text = ""
txtTJabatan.Text = ""
txtGKotor.Text = ""
txtPPN.Text = ""
txtGBersih.Text = ""

'Clear the radio option
OptKawin.Value = False
OptTKawin.Value = False

'Disable the textbox, radio options
'The following program code to be used again when the desired charging
'Data. To code a program that would make a great repeatedly invoked
'A block of programs, whether the procedure or function.
txtNip.Enabled = False
txtNama.Enabled = False
txtJAnak.Enabled = False
txtGPokok.Enabled = False
txtTIstri.Enabled = False
txtTAnak.Enabled = False
txtTJabatan.Enabled = False
txtGKotor.Enabled = False
txtPPN.Enabled = False
txtGBersih.Enabled = False
OptKawin.Enabled = False
OptTKawin.Enabled = False

'Fill groups
cboGol.AddItem ("Select Group")
cboGol.AddItem ("I")
cboGol.AddItem ("II")
cboGol.AddItem ("III")
cboGol.AddItem ("IV")

'Fill Position
cboJabatan.AddItem ("Select Title")
cboJabatan.AddItem ("Operational")
cboJabatan.AddItem ("Tactics")
cboJabatan.AddItem ("Strategic")

'Activate data information in both combobox and Position Classification
cboGol.ListIndex = 0
cboJabatan.ListIndex = 0

'Disable combobox
cboGol.Enabled = False
cboJabatan.Enabled = False

'Non-switch command canceled, the process
cmdBatal.Enabled = False
cmdProses.Enabled = False

End Sub

3. When you Command-click the process in
a. Test whether the textbox and combobox is filled
b. Determine salary basic salary, allowances wife, children,
Define VAT, gross salary and net salary
c. Disable command Process
d. Activate New command

Private Sub cmdBaru_Click ()
'Activate the option not to marry radion
OptTKawin.Value = True

'Disable textbox field of child
txtJAnak.Enabled = False

'Clear the textbox
txtNip.Text = ""
txtNama.Text = ""
txtJAnak.Text = ""
txtGPokok.Text = ""
txtTIstri.Text = ""
txtTAnak.Text = ""
txtTJabatan.Text = ""
txtGKotor.Text = ""
txtPPN.Text = ""
txtGBersih.Text = ""

'Enabled textbox
txtNip.Enabled = True
txtNama.Enabled = True
txtGPokok.Enabled = True
txtTIstri.Enabled = True
txtTAnak.Enabled = True
txtTJabatan.Enabled = True
txtGKotor.Enabled = True
txtPPN.Enabled = True
txtGBersih.Enabled = True
OptKawin.Enabled = True
OptTKawin.Enabled = True

'Enabled combobox
cboGol.Enabled = True
cboJabatan.Enabled = True

'Activate and cancel process command
cmdProses.Enabled = True
cmdBatal.Enabled = True

'Disable the new command
cmdBaru.Enabled = False

'Focus to the textbox Nip kurson
txtNip.SetFocus
End Sub

4. Number of children can be charged if the mating status
Private Sub OptKawin_Click ()
txtJAnak.Enabled = True
txtJAnak.SetFocus
End Sub

5.If unmarried status of the child can not fill and empty values
Private Sub OptTKawin_Click ()
txtJAnak.Enabled = False
'Clear the number of children
txtJAnak.Text = ""
End Sub

7. If clicked, the process is calculated then verify
a. whether the data Nip, has condition name, class and positions have been selected
b. determine the basic salary, allowances of office, benefits and wife,
child allowances, gross salaries, VAT, and net salary
c. Show the basic salary, position allowance, allowances for wives,
child allowances, gross salaries, VAT, and net salary
d. disable command Process
e. New command Aktikan

Private Sub cmdProses_Click ()
Dim GajiPokok, GajiKotor, VAT As Single
Dim TunjanganJabatan, TunjanganIstri, TunjanganAnak As Long

'Test whether the charged Nip
If (Trim (txtNip.Text = "")) Then
MsgBox ("Nip Empty")
txtNip.SetFocus
Exit Sub
End If

'Test whether the name is already filled
If (Trim (txtNama.Text = "")) Then
MsgBox ("Empty Names")
txtNama.SetFocus
Exit Sub
End If

'Test whether the group has been selected
If (cboGol.ListIndex = 0) Then
MsgBox ("Select Group")
cboGol.SetFocus
Exit Sub
End If

'Test whether the position has been selected
If (cboJabatan.ListIndex = 0) Then
MsgBox ("Select Group")
cboJabatan.SetFocus
Exit Sub
End If

'Test whether jlhanak already filled when the mating status
If (OptKawin.Value = True) Then
If (Trim (txtJAnak.Text = "")) Then
MsgBox ("Enter Number of Children")
txtJAnak.SetFocus
Exit Sub
End If
End If

'Determine the basic salary
If (cboGol.Text = "I") Then
GajiPokok = 1000000
Elseif (cboGol.Text = "II") Then
GajiPokok = 2000000
Elseif (cboGol.Text = "II") Then
GajiPokok = 3000000
Else
GajiPokok = 4000000
End If

'Determine the allowances of office
If (cboJabatan.ListIndex = 1) Then 'If Not Have a Job
TunjanganJabatan = 0
Elseif (cboJabatan.ListIndex = 1) Then 'If Not Have a Job
TunjanganJabatan = 500 000
Elseif (cboJabatan.ListIndex = 1) Then 'If Not Have a Job
TunjanganJabatan = 1000000
Else
TunjanganJabatan = 1500000
End If

'Define Allowances wife
If (OptKawin.Value = True) Then
TunjanganIstri = 100 000
'Define the Child Benefit
If (txtJAnak.Text> 3) Then 'Children> 3
TunjanganAnak = 3 * 50 000
Else
TunjanganAnak = txtJAnak.Text * 50 000
End If
Else
TunjanganIstri = 0
TunjanganAnak = 0
End If

'Determine the Gross Salaries, VAT
GajiKotor = GajiPokok + TunjanganJabatan + TunjanganIstri + TunjanganAnak
VAT = 0.1 * GajiKotor
GajiBersih = GajiKotor - VAT

'Move to the textbox Basic Salary, Allowances Wife
'Benefit Children, Position Allowance
'Gross Salaries, VAT, Net Salary

txtGPokok.Text = Str (GajiPokok)
txtTJabatan.Text = Str (TunjanganJabatan)
txtTIstri.Text = Str (TunjanganIstri)
txtTAnak.Text = Str (TunjanganAnak)
txtGKotor.Text = Str (GajiKotor)
txtPPN.Text = Str (VAT)
txtGBersih.Text = Str (GajiBersih)

'Disable the command process
cmdProses.Enabled = False

'New command switch
cmdBaru.Enabled = True

End Sub

8. If the command is clicked Cancel
'Clear the textbox, radio option, combobox
'Disable textbox, radio option, combobox
'Non-switch command and cancel the process

'All the functionality available in the form load event
'Call Form_Load event
Form_Load

'New command switch
cmdBaru.Enabled = True
End Sub

9. If the click command Exit
Test whether completely out, if so close the application, if not re-
to the application
Private Sub cmdTutup_Click ()
If MsgBox ("Yakin Exit", vbOKCancel + vbDefaultButton2, "Close Application") = vbOK Then
End
End If
End Sub
READ MORE - Salary Calculation Visual Basic

Addition operation on the matrix

Addition operation on the matrix

There are a variety of operations on matrices such as:
- Sum
- Reduction
- Multiplication
- Transpose
- Inverse
- Etc.

the discussion this time will be explained about the sum matrix.

A (m, n) is called a matrix A with row m and column n.

On the position of rows and columns can be put matrix elements. For example in row 1 and column to be written A-1 (1.1) can be given a value. Illustration of the matrix elements of the matrix A (3.3) are:
A1, 1 A1, 2 A1, 3
A2, 1 A2, 2 A2, 3
A3, 1 A3, 2 A3, 3

In the example above that there is a matrix A (3.3) which means that the matrix A consists of 3 rows and 3 columns.

For example, elements of the matrix A (3.3):
2 4 5
6 7 8
9 10 11

To add two matrices can be written as follows:
C = A + B, which means that the matrix A plus a matrix B the result is a matrix C

In the previous explanation mentioned that every matrix has rows and columns that form the sum above we can write to:
C (m, n) = A (m, n) + B (m, n)
where m is a count of line matrix
n is a count of the column matrix

In summing two or more matrices that many rows and columns of the matrix that will be summed to be the same.

For example there is a matrix A (2.2) and B (2.2) as below:
Matrix A
2 3
4 2
Matrix B
5 6
7 8

Perjumlahan matrix A and B are
Matrix A Matrix B
2 3 5 6
4 2 7 8

C (1,1) = A (1,1) + B (1,1)
= 2 + 5
= 7
C (1,2) = A (1,2) + B (1,2)
= 3 + 6
= 9
and so on

Matrix implementation in the programming language we can do by using the Array.

Suppose there is a matrix A (2,2)-elemenya that element is an integer, then the declaration of the matrix A in Visual Basic can be done as follows:

Dim A (2,2) As Byte

Above declaration states that there are four identifiers as follows:
A (1,1)
A (1,2)
A (2,1)
A (2.2)

Algorithm sum of two matrices
0. Start
1. Determine the matrices A and B
2. Repeat I started from 1 to many lines of matrix A
3. Repeat J ranging from 1 to many columns matrix A
4. Matrix C = Matrix A + Matrix B
5. Repeat J
6. Repeat I
7. Completed
Private Sub Form_Activate ()
Dim I, J As Byte
Dim A (2,2), B (2.2), C (2.2) As Byte
A (1,1) = 2: A (1,2) = 3: A (2,1) = 4: A (2,2) = 2
B (1,1) = 5: B (1,2) = 6: B (2,1) = 7: B (2,2) = 8

'Sum of Matrix A and B
For I = 1 To 2 Step 1
For J = 1 To 2 Step 1
C (I, J) = A (I, J) + B (I, J)
Next J
Next I

'Print matrix C
For I = 1 To 2 Step 1
For J = 1 To 2 Step 1
Print C (I, J);
Next J
Print
Next I
End Sub
READ MORE - Addition operation on the matrix

Creating a program in VB 2008 Addition

Creating a program in VB 2008 Addition

Finally I can give visual basic programming articles my first 2008. We learn from the most basic first ya friends. This time I want to provide materials on how to program the sum in vb 2008. Well, after you are at page work vb 2008, then you have to do is create a form as below.

Sorry if not good formnya design. But our first try is like this. Well, to create a form like this, how to drag the label contained in the toolbox into the form and then in the Properties box look for writing text, then replace the text Label1 with A:. Next drag the TextBox to the form and place it in addition to writing A: or in addition to Label1. Follow the steps above to make a B. Then drag the Button and place it under textbox2. In the Properties box, change the Text on button1 to "count". Well, now you have to know how to make the design program. Next, your job is to create a design form as shown above. You can design your programs as they pleased, provided a neat and pleasing to the eye of the eye.
Next click on the button1 twice or count. Then enter the following code.

Private Sub Button1_Click (ByVal sender As System.Object, ByVal e As System.EventArgs) handles Button1.Click
TextBox3.Text = Val (textBox1.Text) + Val (TextBox2.Text)
End Sub
End Class

Explanation: The red color code above is code that is contained or directly there when we had double-click on button1, or measure. While we add or enter the code orange.
The definition of code orange is, if button1 is clicked, the value of teksbox3 is the result of the sum value and teksbox2 teksbox1.

Then, double click on button2 or exit. Next add the following code:

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

End Function of code is to stop the program.
Well, if it is to press F5 to compile and run the program. If you have, and successful, then the program will run, you can try to input some numbers. Approximately result will be like the picture below.

Well, if the program is running well, you can compile your programs by clicking the Build menu, then click the Windows Desktop Build and wait for the compilationcompleted . Then save the program by clicking File, Save All.

So that I can explain about the basic programming visual basic 2008 this time. Sorry if I'm way less good submission.
READ MORE - Creating a program in VB 2008 Addition

Toyota Corolla is a smart flamboyant

Toyota Corolla is a smart flamboyant vehicle that has been engineered precisely to present the rider with a feeling of driving a sports car. The frontal of the car has been fashioned with Toyota’s logo, headlamps (with a sharp appearance), grille and the bumper just like the other model of the manufacturer, Camry.

Design and Interior
The inside of the car has been ergonomically designed to provide enormous cabin space to the occupants. Salient features such as automatic air conditioner, heater, music system with 6 CD Changer, power steering, power windows (front and rear), fog lamps, body colour bumper, cigarette lighter, steering lock, light off or on reminder, rear defogger, adjustable steering wheel, molded floor and trunk carpet, 15inch alloy wheel, tachometer are already allocated in the car.

Richly appointed interiors of Toyota Corolla are enhanced by the wood trim on the steering wheel, doors and gear knob. The curved flowing center console is accentuated with silver finish on the edges. The cabin has enough boot space. Convenient storage compartments have been provided in the nooks and corners of the car. Effective air conditioning ensures that passengers are comfortable in any kind of weather.
READ MORE - Toyota Corolla is a smart flamboyant

Sub AutoOpen()

I’d like to discuss using macros to overcome a big limitation with Word’s Autocorrect feature: the expansion of single-character autocorrect entries in words with apostrophes before the last character.

Suppose the letter “t” is set to expand into the word “the.” This will work as it should in most cases, except when typing words like “don’t.”

Normally, autocorrect would expand this into “don’the.” The same problem happens if entries are defined for any of the letters occurring at the end of words like “he’s,” “I’m,” “we’d,” and so on.

Thankfully, there’s a workaround: the autoexec macro. Here’s what a stripped down version of mine looks like:

Sub AutoOpen()

‘ Forces correct Autocorrect behavior
With AutoCorrect.Entries
.Add Name:=”‘s”, Value:=”‘s”
.Add Name:=”‘m”, Value:=”‘m”
.Add Name:=”‘d”, Value:=”‘d”
.Add Name:=”‘t”, Value:=”‘t”

.Add Name:=”‘s.”, Value:=”‘s.”
.Add Name:=”‘m.”, Value:=”‘m.”
.Add Name:=”‘d.”, Value:=”‘d.”
.Add Name:=”‘t.”, Value:=”‘t.”
End With

End Sub

Throw this into your vb module, restart word, and now autocorrect should behave correctly.
READ MORE - Sub AutoOpen()

Visual Basic Compiler

Visual Basic Compiler programming language. The most common form of output from a Java compiler is Java class files containing platform-neutral Java bytecode. There exist also compilers emitting optimized native machine code for a particular hardware/operating system combination.

Option --------  Purpose

/nologo --------- Suppresses compiler banner information.

/utf8output ------ Displays compiler output using UTF-8 encoding.

/verbose ---------  Outputs extra information during compilation
READ MORE - Visual Basic Compiler

Sunday, June 5, 2011

Operations on stream (Stream)

Operations on stream (Stream)

Basic class I / O Reader, Writer, InputStream, and OutputStream provide only operations I / O is very basic. For example, InputStream class has instance methods
public int read () throws IOException

to read one byte of data from the input stream. If until the end of the input stream, the method read () will return the value -1. If there are errors that occur when taking input, then an exception IOException will be thrown. Because IOException is a class exemption that must be dealt with, meaning we must use the method read () inside the try statement or set subroutine throws IOException. (See again the discussion of exceptions in the previous chapter)

InputStream class also has methods to read a few bytes of data in a single step into an array of bytes. However, InputStream does not have a method to read the other data types, like int or double from the stream. This is not a problem because in practice we will not use object of type InputStream directly. We will use is a subclass of InputStream that have multiple input methods are more diverse than the InputStream itself.

So is the OutputStream class has a primitive output method for writing one byte of data to the output stream, the method
public void write (int b) throws IOException

But, we almost certainly will use derivatives class capable of handling more complex operations.

Reader and Writer classes have almost the same basic operations, namely read and write, but this class-oriented character (because it is used to read and write data to human readable). This means that read and write operations will take and write char values ​​rather than bytes. In practice we will use a class derived from these base classes.

One interesting thing from the package I / O in Java is a possibility to increase the complexity of a flow stream by wrapping it in another stream object. This wrapper object is also a stream, so that we can also read and write from the same object with additional capabilities in the object wrapper.

For example, PrintWriter is a subclass of Writer that has additional methods for writing Java data type in characters that can be read of Human. If we have an object of type Writer or their derivatives, and we want to use the method on the PrintWriter to write data, then we can wrap the object in the object Writer PrintWriter.

Example if baskomKarakter of type Writer, then we can make
PrintWriter printableBaskomKarakter = new PrintWriter (baskomKarakter);

When we write data to printableBaskomKarakter PrintWriter method on more sophisticated, then the data will be placed in the same place as when we write directly on baskomKarakter. That means we only need to create a better interface for the same output stream. Or in other words for example we could use a PrintWriter to write the file or send data on the network.

For details, methods of PrintWriter class has the following methods:
/ / Method to write data in
/ / Human readable form
public void print (String s)
public void print (char c)
public void print (int i)
public void print (long l)
public void print (float f)
public void print (double d)
public void print (boolean b)

/ / Write a new line to flow
public void println ()

/ / This method is the same as above
/ / But the output is always
/ / Plus the new row
public void println (String s)
public void println (char c)
public void println (int i)
public void println (long l)
public void println (float f)
public void println (double d
public void println (boolean b)

Note that the above methods do not ever throw an exception IOException. However, the PrintWriter class has a method
public boolean checkError ()

which will return true if there are errors that occur when writing into the stream. PrintWriter Class IOException catch exceptions internally, and set a specific value in this class if an error has occurred. So that we can use the PrintWriter methods without worrying should catch exceptions that may occur. However, if we want to make the program a tough course, we must always call checkError () to see if an error has occurred when we use one method of PrintWriter.

When we use PrintWriter methods to write data to a stream, the data is converted into a series of characters that can be read by humans. How do if we want to make the data in the form of machine language?

Java.io package has a byte stream classes, namely DataOutputStream can be used to write a data into a stream in binary format. DataOutputStream closely related to the OutputStream as the relationship between PrintWriter and Writer.

That is, OutputStream only contains basic methods for writing bytes, DataOutputStream has methods while writeDouble (double x) to write a double value, writeInt (int x) to write the value of int, and so on. And also we can wrap an object of type OutputStream or its derivatives into the stream DataOutputStream so that we can use more complex methods.

For example, if baskomByte is a variable of type OutputStream, then
BaskomData = new DataOutputStream DataOutputStream (baskomByte);

to wrap baskomByte in baskomData.

To retrieve data from the stream, has java.io DataInputStream class. We can wrap an object of type InputStream or their derivatives into an object of type DataInputStream. Methods in the DataInputStream for reading binary data can be used readDouble (), readInt () and so on. Data written by DataOutputStream is guaranteed to be read back by the DataInputStream, although we write data on one computer and read data on other types of computers with different operating systems. Compatibility binary data in Java is one of the benefits to be dijalakan Java on a variety of platforms.

One sad fact about Java is that the Java does not have the class to read data in a form that can be read by humans. In this case, Java does not have the class PrintWriter as opposed to DataOutputStream and DataInputStream. However, we still can make the class itself and use it in a way that exactly the same as classes above.

PrintWriter Class, DataInputStream and DataOutputStream allows us to input and output of all primitive data types in Java. The question is how we read and write an object?

Maybe we would traditionally make their own function to format our object into a certain shape, such as the sequence of primitive types in binary or character is then stored in a file or sent over the network. This process is called serialization (serializing) the object.

On input, we should be able to read serialized data are consistent with the format used at the time of this object serialized. For small objects, this kind of work may not be a big problem. However, for large object sizes, this is not easy.

However, Java has a way to input and output of content objects automatically, ie by using ObjectInputStream and ObjectOutputStream. These classes are subclasses of InputStream and OutputStream that can be used to read and write objects that are serialized.

ObjectInputStream and ObjectOutputStream is a class that can be covered by other classes InputStream and OutputStream. This means we can do input and output byte stream object on anything.

Metde to the object I / O is the readObject () which is available on the ObjectInputStream and writeObject (Object obj) available in ObjectOutputStream. Both can throw IOException. Remember that the readObject () returns a value of type Object, which means must be type cast to type real.

ObjectInputStream and ObjectOutputStream only work for objects that implement the interface named Serializable. Lbih far all the instance variables of the object must be serialized, because the methods of Serializable interface does not have anything. This interface exists only as a marker for the compiler so the compiler knows that this object is used to read and write to the media.

What we need to do is add "implements Serializable" to the class definition. Many of the Java standard class that has been declared to be serializable, including all components of Swing and AWT classes. This means that GUI components can be stored and read from the device I / O using ObjectInputStream and ObjectOutputStream.
READ MORE - Operations on stream (Stream)

Stream, Reader, dan Writer

Stream, Reader, dan Writer

Computer programs can be useful if he could interact with other worlds. Interaction here means input / output or I / O. In this chapter, we will see the input / output on files and network connections (network). In Java, the input / output on the file and the network is based on the flow (stream), where all objects can do the I / O is the same. Standard output (System.out) and standard input (System.in) is an example of the flow.

To work with files and networks, we need knowledge about the exception, which has been discussed previously. Many subroutines are used to working with I / O throw an exception that must be addressed. This means that the subroutine must be called within the try statement ... so catch exceptions that occur can be handled properly.

Without being able to interact with the other world, a program is useless. Interaction of a program with other world is often called input / output or I / O. From the first, one of the biggest challenges for designing a new programming language is to prepare the facility to input and output. Computers can connect with various types of input and output of various devices. If the programming language must be created specifically for each type of device, the complexity will no longer be handled.

One of the biggest advances in the history of programming is the concept (or abstraction) to model the device I / O. In Java, abstraction is called the flow (stream). This section will introduce the flow, but does not explain the complete. For more details, please refer to official documents Java.

When dealing with input / output, we must remember that there are two general categories of data: data created by the machine and human readable data. The data that made the engine written with the same model with how data is stored in the computer, namely a series of zeros and ones. Human-readable data is data in the form of a series of letters. When we read a number is 3.13159, we read it as a series of letters which we translate as numbers. This number will be written in a computer as a series of bits that we do not understand.

To deal with both types of data, Java has two broad categories for streams: byte streams for machine data (byte stream), and flow character (character stream) for human-readable data. There are many classes derived from both these categories.

Any object that issued the data to a stream of bytes into a class derived from abstract class OutputStream. Objects that read data from a byte stream derived from the abstract class InputStream. If we write numbers to an OutputStream, we will not be able to read the data because it is written in machine language. However, these data can be read back by the InputStream. The process of reading and writing data will be very efficient, since there is no translation to be done: bits used to store data in computer memory is only copied from and to the flow.

To read and write character data that can be understood by humans, the main classes are Reader and Writer. All character stream classes are subclasses of one of these abstract classes. If a number Writer will be written in the stream, the computer must be able to translate it into a series of characters that can be read maunsia.

Read numbers from the Reader stream into a numeric variable must also be translated, from the sequence of characters into a series of bits that computers understand. (Although for data consisting of characters, like the text editor, there will be some translation done. Characters are stored in a computer in 16-bit Unicode value. For people who use the ordinary alphabet, character data is usually stored in files in ASCII code, that only uses 8-bit. Class Reader and Writer will handle the change from 16-bit to 8-bit and vice versa, and also handle other alphabets used in other countries.)

It is easy to determine whether we should use a byte stream or character stream. If we want the data we read / write for the human readable, so we use the character stream. If not, use a byte stream. System.in and System.out is actually a stream of bytes and not a character stream, hence can handle inputs in addition to the alphabet, for example the enter key, arrows, escape, etc..

Standard flow class that will be discussed later defined in the java.io package along with several other auxiliary classes. We have to import classes from this package if you want to use them in our program. This means that by using the "import java.io. *" at the beginning of our source code.

The flow is not used in the GUI, because the GUI has a flow of I / O itself. However, these classes are used also for the files or communications in the network. Or it could also be used for communication between the threads that work simultaneously. And there is also a flow class that is used to read and write data to and from computer memory.
READ MORE - Stream, Reader, dan Writer

example, we're connecting to a local Interbase server

JDBC connection to an Interbase database. In this example, we're connecting to a local Interbase server using the JDBC ODBC bridge driver after setting up Interbase as an ODBC datasource on the local system.
// Establish a connection to an Interbase database using JDBC and ODBC.
import java.sql.*;

class JdbcTest1
{
public static void main (String[] args)
{
try
{
// Step 1: Load the JDBC ODBC driver.
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
// Step 2: Establish the connection to the database.
String url = "jdbc:odbc:contact_mgr";
Connection conn = DriverManager.getConnection(url,"user1","password");
}
catch (Exception e)
{
System.err.println("Got an exception! ");
System.err.println(e.getMessage());
}
}
}
READ MORE - example, we're connecting to a local Interbase server

Now all we have to do is close the connection

Now all we have to do is close the connection. Actually we should close all of the instances of Connection, Statement and ResultSet and
it's done in reverse order from which they were created:


if (rs != null)
rs.close();
if (statement != null)
statement.close();
if (con != null)
con.close();


For many of the code statements above it is required to handle an SQLException in case anything goes wrong.
Thus you'll have to enclose much of the code in a try / catch block which were excluded in the example to make it more readable.


// Declare the variables outside the try block to be able to call them
// in a finally block where the closing should take place.
Connection con = null;
Statement stmt = null;
ResultSet rs = null;


try {

//all code here

} catch (SQLException ex) {

ex.printStackTrace();

} finally {

//the code for closing here
}
READ MORE - Now all we have to do is close the connection

what other tools exists to capture database level data

Both SQL Server and Windows offer a lot of data to help troubleshoot and monitor overall usage and performance for your SQL Server databases. Within SQL Server there are several DBCC commands as well as a lot newly exposed data from the Dynamic Management Views in SQL Server 2005.

One way of monitoring your individual database usage is to view the data from the dbo.sysprocesses table or sys.sysprocesses in SQL 2005. This data is also exposed by either using the GUI tools or by running sp_who2. From this you can tell who is currently connected to each database and the activity that is occurring, but it is not very easy to create a baseline or a trend from this data. Another approach is to run a server side trace or use Profiler to capture the data. This may be helpful, but this may give you too much information as well as still having the need to extract the data to figure out what is going on within each database. So what other tools exists to capture database level data?

Solution
Most DBAs and developers probably use Profiler, trace, review query plans, run sp_who2, run DBCCs, etc... to capture data to figure out what is currently running on the database server. These tools are great, but don't give you the entire picture in an easy to use way.

Another tool that all DBAs and developers should use is Performance Monitor. This OS level tool provides great insight into Windows counters, but also into specific SQL Server counters. There are hundreds of counters that are exposed within this tool and there are several that are specific to SQL Server.

To launch Performance Monitor, click Start, Run... and type in "perfmon" and the following should open. This application can also be found under the Administrative Tools.

To add a counter, click on the + icon or use Ctrl + I and the following will open.
Most of the counters are server specific and do not give you insight into each individual database, but the following list of counters are at the database level, so this means you can collect this data for each database that is on the server as well as an overall count for all databases.
READ MORE - what other tools exists to capture database level data

To setup dual monitors in Ubuntu

 
To setup dual monitors in Ubuntu, we need to modify the file called xorg.conf inside of /etc/X11

1. After finished installing Ubuntu, go to your Terminal Window in Applications-Accessories-Terminal, then type the following:

sudo cp /etc/X11/xorg.conf /etc/X11/xorg.conf-old


This is to backup the original setting in case we need to reset the display.

2. Edit the xorg.conf by typing the following in the Terminal:

sudo gedit /etc/X11/xorg.conf

Make sure “glx” is under module section, if not replaced “nv” with “glx”

3. Edit Screen setting by insert these codes under the Screen

Option “RenderAccel” “true”

Option “TwinView”


Option “MetaModes” “1280×1024 1280×1024″ <—YOUR ACTUAL LCD’S RESOLUTIONS

Option “TwinViewOrientation” “RightOf”

You can use “LeftOf” or “BelowOf” if you’d like to

Save xorg.conf, and close it.

Now logout of your section. When you log back in, you should have your twinview working.

Troublshooting: If you cannot access login screen after restart/logout, enter username/password at command line, then type the following to restore your display:

sudo cp /etc/X11/xorg.conf-old /etc/X11/xorg.conf

Restart your system, your login screen should be back.
READ MORE - To setup dual monitors in Ubuntu

Oracle database consists of a collection

An Oracle database consists of a collection of data managed by an Oracle database management system. You can download Oracle Database XE server for Debian, Mandriva, Novell, Red Hat and Ubuntu Linux distributions. First you need to get databases up and running in order to use Oracle. The Oracle database has had a reputation among new Linux users as difficult to install on Linux systems. Now Oracle Corporation has packaged recent versions for several popular Linux distributions in an attempt to minimize installation challenges beyond the level of technical expertise required to install a database server.

Make sure you have enough disk space and memory

If you have less than 1GB memory run the following commands to create swap space:
$ sudo dd if=/dev/zero of=/swpfs1 bs=1M count=1000
$ sudo mkswap /swpfs1
$ sudo swapon /swpfs1
Debian / Ubuntu Oracle installation

First modify /etc/apt/sources.list file:
$ sudo vi /etc/apt/sources.list

Append following line:
deb http://oss.oracle.com/debian unstable main non-free

Save and close the file. Next import GPG key:
$ wget http://oss.oracle.com/el4/RPM-GPG-KEY-oracle -O- | sudo apt-key add -

Update package database:
$ sudo apt-get update

Finally install Oracle:
$ sudo apt-get install oracle-xe

Output:
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following packages were automatically installed and are no longer required:
linux-headers-2.6.20-15-generic linux-headers-2.6.20-15
Use 'apt-get autoremove' to remove them.
The following extra packages will be installed:
libaio
The following NEW packages will be installed:
libaio oracle-xe
0 upgraded, 2 newly installed, 0 to remove and 2 not upgraded.
Need to get 221MB/221MB of archives.
After unpacking 405MB of additional disk space will be used.
Do you want to continue [Y/n]? y
Get:1 http://oss.oracle.com unstable/non-free oracle-xe 10.2.0.1-1.1 [221MB]
....
....
Post-install configuration

You must configure Oracle TCP/IP port and other parameters. Simply type the following command:
$ sudo /etc/init.d/oracle-xe configure

Output:
Oracle Database 10g Express Edition Configuration
-------------------------------------------------
This will configure on-boot properties of Oracle Database 10g Express
Edition. The following questions will determine whether the database should
be starting upon system boot, the ports it will use, and the passwords that
will be used for database accounts. Press to accept the defaults.
Ctrl-C will abort.

Specify the HTTP port that will be used for Oracle Application Express [8080]: [Enter key]

Specify a port that will be used for the database listener [1521]:[Enter key]

Specify a password to be used for database accounts. Note that the same
password will be used for SYS and SYSTEM. Oracle recommends the use of
different passwords for each database account. This can be done after
initial configuration:secret
Confirm the password:secret

Do you want Oracle Database 10g Express Edition to be started on boot (y/n) [y]:y

Starting Oracle Net Listener...Done
Configuring Database...Done
Starting Oracle Database 10g Express Edition Instance...Done
Installation Completed Successfully.
To access the Database Home Page go to "http://127.0.0.1:8080/apex"

To access the Database Home Page go to http://127.0.0.1:8080/apex. Open a web browser and type url (you need to use username "system" and password setup earlier)
READ MORE - Oracle database consists of a collection
 
THANK YOU FOR VISITING