Showing posts with label Computer Programming. Show all posts
Showing posts with label Computer Programming. Show all posts

Monday 13 January 2014

VB language reference (Keywords) [List of functions/methods]

Source: http://msdn.microsoft.com/en-us/library/xw8td0cx.aspx

Arrays Summary (Visual Basic)
What can be do to array? Action:
1. Verify an array: IsArray
2. Declare and initialize an array: Dim, Private, Public, ReDim
3. Find the limits of an array: LBound, UBound
4. Reinitialize an array: Erase, ReDim

Collection
Actions:
1. Create a collection object
2. Add an item to a collection
3. Remove an object from collection
4. Reference an item in a collection
5. Return a reference to an IEnumerator interface

Compiler Directive summary
Actions:
1. Define a compiler constant: #Const directive
2. Compile selected blocks of code
3. Collapse and hide sections of code
4. Indicate a mapping between source lines and text external to the source

Control flow summary
Actions:
1. Branch: GoTo, On Error
2. Exit or pause the program: End, Exit, Stop
3. Loop: Do...Loop, For...Next, For Each...Next, While...End While, With
4. Make decisions: Choose, If ... Then ... Else, Select Case, Switch
5. Use procedures: Call, Function, Property, Sub

Conversion Summary
Actions:
1. Convert ANSI value to string
2. Convert string to lowercase or uppercase: Format, LCase, UCase
3. Convert date to serial number: DateSerial, DateValue
4. Convert decimal number to other base: Hex, Oct
5. Convert number to string: Format, Str
6. Convert one data type to another: CBool, CByte, CDate, CDbl, CDec, CInt, CLng, CSng, CShort, CStr, CType, Fix, Int
7. Convert date to day, month, weekday or year: Day, Month, Weekday, Year
8. Convert time to hour, minute, or second: Hour, minute, or second
9. Convert string to ASCII value: Asc, AscW
10. Convert string to number: Val
11. Convert time to serial number: TimeSerial, TimeValue

Data type summary

Dates and time summary
1. Get the current date or time: Now, Today, TimeOfDay
2. Perform date calculation: DateAdd, DateDiff, DatePart
3. Return a date: DateSerial, DateValue, MonthName, Weekdayname,
4. Return a time: TimeSerial, TimeValue
5. Set the date or time: 
6. Time a process: Timer


Declarations and Times summary
Action:
1. Assign a value: Get, Property
2. Declare variables or constants: Dim, Public, Private, Shadow, Protected, Shared, Const, Statc
3. 

Directories and files
Action:
1. Change a directory of files
2. Change the drive
3. Copy a file
4. Make a folder or make a directory
5. Remove directory or folder
6. Rename a file, rename a folder, rename folder
7. Remove a directory or folder
8. Return the current path
9. Return

Errors summary
1. Generate run-time errors
2. Get exceptions
3. Provide error information
4. Trap errors during run time
5. Provide line number of error
6. Provide system error code

Information and interaction summary
1. Run other programs: AppActivate, Shell (Ready)
2. Call a method or property: CallByName
3. Sound a beep from computer: Beep (Ready)
4. Provide a command-line string: Command
5. Manipulate COM object: CreateObject, GetObject
6. Retrieve color information: QBcolor, RGBColor
7. Control dialogboxes: InputBox, MessageBox


Input and Output summary
1. Access or create a file: Fileopen
2. Closefiles: fileclose, reset
3. Control output sequence
4. Copy a file
5. Get information about a file
6. Get or provide information from/to the user by means of a control dialog box.
7. Manage files
8. Read from a file
9. Return length of a file
10. Set or get file attributes
11. Set read-write position in a file
12. Write to a file

My reference
1. Accessing application information and services
2. Accessing the host computer and its resources, services and data
3. Accessing the forms in the current project
4. Accessing



Web browser mine

Features:
1. Text highlighting
2. Text translation (pop-up)
3. Text notepadding

You want your software connect to the microsoft office programs?

Use COM and namespace
Because microsoft office contain code and dll

namespaces

What namespaces do they easier to organize the classes.

One namespace several different classes

Saturday 11 January 2014

Looping

Components

Looping's components: (a = b x c)
(a) what to be looped(b)
(b) how many times (c)
- Unknown
- Known

(c) result
(d) exit condition or stop condition

Which one?
If you know what to be looped and how many times you loop and what to be looped, you can use for.
If you don't know how many times you loop but know what to be looped and the what result you want, you can use while.

For: a, b, c
While: d

Examples
Python looping
- Python For
Example (Python)
>>> for i in range (0,2):
    print i

  
0
1
- Python While
 Example (Python):
>>> x=1
>>> while x < 3:
    x = x + 1
    print x

  
2
3

C Looping
- For
Usage: for (start counter; end counter; how to get to end counter)

Example:

- While
 This the most basic loop in C.
check first, do last.

Example:



- do..While
do.. While loop is just like while except the condition to test is behind
do first, check later




Event driven programming

What you act upon ,,,,,


Is...

Visual basic

Isnothing
Return true if it is nothing

Isarray
Return true if it is an array

Isdate
Return true if it is date

IsDBNull

Iserror
Return true if it error

IsNumeric
Return true if it is a Numeric

IsReference
Return true if it is a reference

Microsoft built-in function
=Isblank
=Iserr
=Iserror
=Iseven
=IsLogical
=IsNA
=IsNontext
=IsNumber
=IsODD
=IsPMT
=Isref
=Istext

Friday 10 January 2014

Visual Basic

Creating ur first visual basic program
Notepad + command line compiler

Array
Create an array

Dim number(0 to 2) as integer
    number(0) = 1
    number(1) = 2


Function
Create function/method

1.Function that return a method but not take parameter
function sandirahasia() as String
    return "Aloha!"
end function

2. Function that return an output and take parameter

function sandirahasia2(ByVal name as String) as String
    return "Aloha" & name
end function


Call our function
Style 1:
sub main()
    dim my_string = sandirahasia() as String
    console.writeline(my_string)
end sub

Style2:
sub main()
    console.writeline(sandirahasia())
end sub

Style1 and style 2 the result is the same

While

Contoh 1: While sederhana

Module Module1

    Sub Main()
        Dim perutgue As Integer = 0
        While perutgue < 10
            perutgue = perutgue + 1
        End While
        Console.WriteLine("Gue kenyang!")
        Console.ReadLine()
    End Sub
End Module

If

Module Module1

    Sub Main()
        Dim lampu = Console.ReadLine()
start:
        If lampu = "merah" Then
            Console.WriteLine("Berhenti")
        ElseIf lampu = "kuning" Then
            Console.WriteLine("Hati-hati")
        ElseIf lampu = "hijau" Then
            Console.WriteLine("Maju")
        End If
        Console.ReadLine()
        If jawab == "y" Then GoTo start
        else console.readline()
        End if

    End Sub

End Module

Server application and client application

Server application
The application will "listen" on a designated port.
When client makes a connection request, the server can then accept request and thereby complete the connection.
Once the connection is complete, the client and server can freely communicate with each other.



Windows programming with C

Hungarian notation used for naming variables.
Hungarian notation requires that a variable be prefixed with an abbreviation of its data type.
Example:
putting letter "P" in front of a data type, or "p" in front of variable usually indicates that the variable is a pointer.

The letter LP stands for "long pointer"

Handle
Handle = a unique identifier
A handle is actually a pointer to a pointer to a memory location.
Handles are unsigned integers that Windows uses internally to keep track of objects in memory.

HWND
What is?
data types that keep tracks of the various object that appear on the screen.

How?


Using the winsock control

http://msdn.microsoft.com/en-us/library/aa733709%28v=vs.60%29.aspx

1. Selecting protocol
2. Set the protocol
3. Determining the name of our computer
4. TCP connection basics
5. Accepting more than one connection request
6. UDP basics
7. About bind method

Class / Objects

What is class?

Using the blueprint analogy, a class is a blueprint, and an object is a building made from that blueprint

Thursday 9 January 2014

TCP vs UDP

TCP
is analogous to telephone
- connection oriented

UDP
is analogous to passing a note from one computer to another computer.
- connectionless protocol
- maximum data size of individual sends is determined by the network

Question to choose between TCP or UDP
1. Require acknowledgement?
2. Sending big file(Such as image or sound file?)
3. Intermittent?





Tasks controlling hardware of PC

1. Sending beep to speaker
2. Ejecting CD/DVD-ROM

Wednesday 8 January 2014

cmp : compare a register to a value, raise a flag

section .data
store variable

section .bss
Used for reservation

section .text
Used for actual codes

Composer

1. Write your code using notepad
2. Save it as .asm file type
3.

Stack

Is just an area,
Everytime you add data to the stack, the stack pointer increment to

Monday 6 January 2014

CMD

ASSOC
ATTRIB
BREAK
BCDEDIT
CACLS
CALL
CD
CHCP
CHDIR
CHKDSK
CHKNTFS
CLS
CMD
COLOR
COMP
COMPACT
CONVERT
COPY
DATE
DEL
DIR
DISKCOMP
DISKCOPY
DISKPART
DOSKEY
DRIVERQUERY
ECHO
ENDLOCAL
ERASE
EXIT
FC
FIND
FINDSTR
FOR
FORMAT
FSUTIL
FTYPE
GOTO
GPRESULT
GRAFTABL
HELP
ICACLS
IF
LABEL
MD
MKDIR
MKLINK
MODE
MORE
MOVE
OPENFILES
PATH
PAUSE
POPD
PRINT
PROMPT
PUSHD
RD
RECOVER
REM
REN
RENAME
REPLACE
RMDIR
ROBOCOPY
SET
SETLOCAL
SC
SCHTASKS
SHIFT
SHUTDOWN
SORT
START
SUBST
SYSTEMINFO
TASKLIST
TASKKILL
TIME
TITLE
TREE
TYPE
VER
VERIFY
VOL
XCOPY
WMIC

Categorize(file, system,
WMI

files tree directory trees

disk's volume label, disk's serial number

Windows version

text file's {contents, print = PRINT}

directory structure's of a drive or directory structure's path

System time [display: TIME]

running process or running application

running task or running services(background processes) [kill: TASKKILL, display/configure: SC]

machine properties and configuration

a path

local shutdown / remote shutdown {=SHUTDOWN}

Batch file {value shifting = SHIFT, SETLOCAL, suspends the processing = PAUSE, conditional processing = IF, end localization = ENDLOCAL, Displays a message / turning-on or turning-off 

Program or command {run seperate programs [START], scheduling to run[SCHTASKS]}

Windows environment variable {Displays, sets, remove}

Directory {remove = RMDIR, RD, current directory back/forward = PUSHD, POPD, create = MKDIR, Display the name of the current directory or changes the current directory}

Files {rename = RENAME, REN, replace = REPLACE, display file share opened = , moving from one directory to another directory = MOVE, type display/modifies = , search for a string in = FINDSTR, search for a text string in a file or files = FIND, compares a set files and show the difference = FC, delete a file/files = ERASE, duplicating one or more files to another location = COPY, compare the content of two of this = COMP, display/change file attributes = ATTRIB, file extension association = ASSOC }

Disk {a bad or defective recover their readable information = RECOVER, create, change, delete the volume label = LABEL, format for to be used with Windows = FORMAT, check disk and displays a status report= CHKDSK}

Command's output {display one at a time = MORE}

a system device {configure = MODE}

a Symbolic link and a hard link {

ACL for files and directories = {Display, modify, backup, or restore ACLs for files and directories = ICACL/CACLS}

Extended character set

Group policy for machine or for user = {GPRESULT}

File system properties = {display, configure = FSUTIL}

device driver {display device driver status and properties = DRIVERQUERY}

disk partition {display

date {displays or sets the date}

Active code page number {Display or sets = CHCP}

Boot database {to sets properties in boot database = BCDEDIT}


Verb:
Delete
Display
Modifies = Change
Recovers
backup
restore
create
moving
shutdown

Objects:
Device driver, properties:
















Sunday 5 January 2014

Windows Assembly (Debugger) lab

1. Cetak Hello World

1. debug
Start MS debug
2. assemble at address 100 (all DOS programs run here)
-a 100
angka 100 sesuai dengan alamat IP
mov ax, 0200
mov dx, 0048
int 21
mov dx, 0065
int 21
mov dx, 006c
int 21
mov dx, 006c
int 21
mov dx, 006f
int 21
mov dx, 0020
int 21
mov dx, 0077
int 21
mov dx, 006f
int 21
mov dx, 0072
int 21
mov dx, 006c
int 21
mov dx, 0064
int 21
mov dx, 0021
int 21
mov dx, 000d
int 21
mov dx, 000a
int 21
int 20 --> interrupts 20: terminates program
-h 014b 0100
-n cetakhelloworld.com
-rcx
:004b
-w
-q