Runing Text

Do not Click

Animation in VB 2005 Console Application

Posted by Andi on Sunday 23 August 2009 , under | komentar (0)




Making animation program using VB 2005 console program is actually very simple application. The principle of actual animation is a process to print something the characters on the screen at some point later in the interval of a few seconds there is a process to delete or print a space so that the characters seem to move. In the VB 2005 console application, to print characters on the screen at point x, y then the syntax used nilaititikx and Console.CursorLeft = Console.CursorTop = y. This syntax is used to direct the cursor to be at the point x, y which have been determined. So that when a character wants to print the screen, always printed where the cursor position. To a point in the VB 2005 Console Application may only be occupied by a single letter (the unit used is the letter). Actual units used not only the letter there was another unit such as pixels, but which are discussed in this section is specific to the letter units.
Point x represents the column, while y represents the line on the screen. Many columns by default there are 80 letters and rows by 25 rows.

Statement is used for animations
- System.Threading.Thread.Sleep (var); this statement is similar to the delay statement on the program C + + or pascal. This statement is used to delay the program execution process for a few milliseconds. Or in other words the program will delay the execution process for a few milliseconds.
- Rnd; used to randomize the numbers. In this program, rnd statement is used to randomize the numbers which generated random numbers leads to the point x or y on the screen. And these numbers will be determined where these characters will be printed.
- Do Until the loop condition; Without repeating the statement animation programs do not go as we expect. Conditions of looping statement that we use for this program is Console.KeyAvailable = True. Which means that as long as there are no key presses from the keyboard, all statements that are inside the do until condition .... loop will be done repeatedly

live in an information technology

Posted by Andi on , under | komentar (0)



You'll realize that you live in an age when information technology:
1. You accidentally press your PIN when turned on the microwave
2. You no longer play solitaire with playing cards truth
3. You send an email to colleagues just a few tables away from you
4. The reason you are not connected with your friends is because they do not have e-mail
5. Each Pariwara ditelivisi there a website address or e-mail
6. Leaving the house without bringing HandPhone make you panic, when you do not have previous HandPhone and it has lasted for tens of years and no problems.
7. You wake up in the morning and immediately Online before drinking coffee.
8. You must turn your head just to smile. :)
9. You immediately know who you'll send this joke.

Array

Posted by Andi on , under | komentar (0)




Array can be interpreted as a sequence of data which is so easy to referenced. Variable used hrus directly referenced using the variable, it will be difficult if there is a lot of data to be processed simultaneously. For example:

Dim a, b, c, d, e as integer
...
Console.writeline (a)
Console.writeline (b)
Console.writeline (c)
Console.writeline (d)
Console.writeline (e)


To display all of variables are necessary because the 5 statements each variable must be mentioned directly. By using the array, the repetition of these constraints can be overcome by using the help of the loop. Array declaration syntax is:

Dim var_name (length) [as data_type]


Or


Dim var_name ()


The first way is used to produce arrays with a fixed element, while the latter will result in an array without a fixed length.

Example:

Myadd Dim as string = "192.168.1.31"
Dim result () as string = myadd.split


Or

Dim result (6) as string = myadd.spilt


By using the dynamic long array elements can be changed when the program starts by using redIm, but its elements will be reset again. To maintain the value of these arrays can be used redIm Preserve.
Example:

RedIm Result (10)
Preserve redIm Result (10)


By default, the array index starts pada.net 0 to length index. So the length of 5 will result in 6 elements (0,1,2,3,4,5). Next arrays can be used directly by accessing its index.
Example:

Dim i (5) as integer
...
Console.writeline (i (0))
Console.writeline (i (1))
Console.writeline (i (2))
Console.writeline (i (3))
Console.writeline (i (4))
Console.writeline (i (5))


For each Clause
For each loop is one that can be used di.Net, However the only useful to use arrays and collection scope. For each clause will make the loop as many elements of the array or collection without the need to specifically mention the specific length, and requires a variable with the type of data in accordance with the elements in the array or collection. Sintaxnya are:
For each var_name [as data_type] in array_name
Next
Example

Dim myarr () as Integer = (1,2,3,4)
For each element as Integer in myarr
Console.writeline (element)
Next

Procedure and function

Posted by Andi on , under | komentar (0)



- Procedure
Procedure is a sub-program that does not return a value. Procedure is widely used for collection of frequently used commands but do not need to return a particular value
Syntax:

Sub nmprocedure (parameters)
Statements
End Sub



Example:

Even Numbers sub print ()
For I as integer = 2 to 200 step 2
Console.writeline (i)
Next
End Sub



Dialing procedure done by writing the name of the procedure with the required parameters (if required).

Sub main ()
Console.writeline ( "Program to write even number from 2-100")
EvenNumbersprint ()
end sub



- Function
Function similar to procedure, but returns to the caller function. Function is widely used to classify the order to conduct a test or calculation of a value.

Syntax:

Nmfunction function (parameters) as [data_type]
Statements
Return value
End function



Default:
If not mentioned [as data_type] will be considered: as object
Function must specify what data type will be returned to the caller and what the value will be returned in accordance with the type of data that has been mentioned. The value written to the command return is the overall value of the function.
Example:

OddFunctionTest (ByVal x as integer) as Boolean
If x mod 2 = 0 then
Return false
Else
Return true
End if
End function


Dialing function is done by writing a function with parameters with (if needed), and performed the function value storage. Could also function values do not need to be accommodated in one variable alone, However the direct use in selection or looping.

Sub main ()
Console.writeline ( "The program determines an odd number")
Console.writeline ( "Enter a number:")
Dim input as integer = console.readline ()
If OddFunctionTest(input)
Console.writeline ( "Odd Numbers")
Else
Console.writeline ( "Number is even")
End if
end sub



- Parameters
Parameter is included in the data pemangilan function or procedure. The data will affect the performance of the procedure or function is called. How to spend (pass) parameters into the procedure there are two ways:
a. Passing by value is a way of passing parameters by copying the value of a variable to the parameter. So if the value is changed parameters will not affect the original variable values.
b. Passing by reference is a way of passing parameters by copying the memory address of the variable to the parameters. So if the value of these parameters changed, this will affect the initial value

Example:

Sub procedure1 (ByVal a as integer, byref b as integer)
A = A +2
B = B +2
End Sub
Sub main ()
Dim X, Y as integer
X = 2
Y = 2
Procedure1 (X, Y)
Console.writeline ( "The value X:" & X)
Console.writeline ( "Value Y:" & Y)
End Sub



Output:
The value X: 2
Value Y: 4

Looping

Posted by Andi on , under | komentar (0)



Loop is a looping technique where the programmer can repeat the command line in the source code as many times as desired. There are several known recurrence in the Visual Basic.Net language, among others:
• For - Next
Repetition is used when there is a repeated command line, and the number of repetitions has been known with certainty.
Syntax:

For variable = initvalue to maxvalue step increment / decrement
Statement for loop
[Exit For]
Next


Step is optional means can be written or not. If not written the default step value is 1. Step is used to increase the value of a variable each time the statement in the for-next repeat. Exit for a way to force out of the loop (optional).
Example: Repetition of the smallest value to largest value

Dim I as integer
For i = 0 to 20 [step 1]
Console.write (i)
Next
Repetition of the greatest value to the smallest value
For I as integer = 20 to 0 step -1
Console.write (i)
Next



Variables can also be directly declared in the for-next relevant as the above example. These variables will be local only for identified on the next.


• Do while - loop
Repetition is used if the number does not necessarily iterasinya. Usually the loop will be finished when found one or several conditions. Loop will be completed if the conditions mentioned in the false worth while.
Syntax:

Do while condition
Statement for loop
[Exit Do]
Loop



Repetition will check the condition before starting the iteration. If the initial condition is not met, then the iteration can not be done at all.
Example:

Dim I as integer = 1
Do while i <5 integer =" 1"> 5
Console.writeline (i)
I + = 1
Loop



• Do - loop while
Almost equal to do while - loops, but the condition will be checked at the end of the loop, so that if the initial condition one, the command line in the loop will still be done once before out of the loop.
Syntax:

Do
Statement for loop
[Exit Do]
Loop while condition



Repetition is a condition check is done once after recurrence. If the initial condition is not met, then the statements inside the loop will only be done once.
Example:

Dim I as integer = 1
Do
Console.writeline (i)
I + = 1
Loop while (i<=5)



• While - end while
This form exactly do while - loops, only suffixes and how to get out of his force from the loop are different. Structure and flow in exactly the same.
Syntax:

While condition
Statement for loop
[Exit While]
End while



Example:


Dim I as integer = 1
While i <5
Console.writeline (i)
I + = 1
End while

Selection

Posted by Andi on , under | komentar (0)



Conditional Selection statement or a statement requesting the computer to perform action selection based on a given condition. VB.Net syntax provides 2 options for branching action where each has his own purposes, namely:
• If Clause
If statement is a selection that is used with the consideration of a condition to do anything if the conditions are right and others may do if the condition is false. Syntax writing is

If condition then
Action if Condition True
End if



If you want to do something else if the condition is false then the syntaxnya are:

If condition then
Action if true condition
Else
Action if condition false
End if



If only support for action 2 for 1 condition, if you want to give more than 2 action could be "nested if" (if in the if). His syntax becomes:

If condition 1 then
Action if true condition 1
Else
If condition 2 then
Action if true condition 2
Else If condition 3 then
Action if condition and condition 2 false 3 true
Else
Action 3 if condition false
End if
End if



• Select case clause
Select case statement is a selection that is used with the consideration of the value of a variable or of a condition. The syntax is:

Select case variable / condition
Value Case 1: statement 1 if the value
Value Case 2: statement 2 if the value
Case 3 value: 3 value if statement
Case else
Statement if no value matched
End select


Example:

Dim q as integer = 2
Strq as string Dim
Select case q
Case 1: strq = "Bad Quality"
Case 2: strq = "Average Quality"
Case 3: strq = "Excellent Quality"
Case else
Console.writeline ( "No Such quality")
End select

Data type in VB 2005

Posted by Andi on , under | komentar (0)



Type the value that can be accommodated by a variable is determined at the time of declaration of variables. Influential in the amount of memory allocated for the variable. Examples of data types in Vb.net:
Byte between 0-255
Short limit value -32,768 - 32,767
Integer limit value -2147483648 - 2147483647
Long accommodate integers
Single accommodate the real numbers
Double accommodate the real numbers
Accommodate decimal decimal
Boolean holds true or false value
Date accommodate the value of the date
Char accommodate one character
String holds more than characters

Type casting / Convert between data types
• Implicit conversion
- Done automatically.
- Occurs when converting from a smaller size to a larger size.
- Example:


Dim length as byte
Length1 as integer Dim
Length = 4
Length1 = length



• Explicit conversion
- Done by using the existing functions.
- Occurs when converting from the type of data that are not similar.
- Function: Cbool (), CDbl (), Cbyte (), Cchar (), Cdate () ...

VB.Net CA

Posted by Andi on , under | komentar (0)



Console Application is one type of application that can be made with the technology. Net. Is a text-based applications and is made if the application does not require a GUI. Example: The application server that served only to serve the client.

Syntax Input Output
Input and output operations are basic operations in programming.
1. Console.write
2. Console.writeline
3. Console.read
4. Console.readline
5. Console.readkey

Variable
A representation of the memory used to hold a value and that value can change during the program starts. Determined by the type of data. Distinction into two types: Local and Global.
Declaration of variables

Dim as


• Example:

Dim totalEmployee As Integer
Dim as String staffName



Terms of naming variables:
- Does not contain special characters
- Not allowed to use the keyword
- Containing numbers and not placed at the beginning.

Related Post