Rabu, 19 Oktober 2011

How to Make Event dan Method On VB

1.1 Creating a User Interface (UI)
Enable VB6 via the Start button.


Setting its properties each object are as follows:

object
properties
value
Form2
Caption
StartUpPosition
Method test
2-centerScreen
List1
-
-
Combo1
-
-
Command1
Caption
Add
Command2
Caption
Delete
Command3
Caption
Clear

1.2 Writing Program Code: Test Method
In the Code Editor type the code is as follows:
Private Sub Form_Load ()
Combo1.AddItem "justin"
Combo1.AddItem "Bieber"
Combo1.AddItem "david"
Combo1.AddItem "Shafira"
end Sub
Private Sub Command1_Click ()
List1.AddItem Combo1.Text
end Sub
Private Sub Command2_Click ()
List1.RemoveItem List1.ListIndex
end Sub
Private Sub Command3_Click ()
List1.Clear
end Sub
 

save form2.
  

Sabtu, 15 Oktober 2011

How To Make Event and Property

1.1 Creating a User Interface (UI):
Enable VB 6 via the Start button.
Identify the types of components (control) which is in the Toolbox:

In Window Form UI make it like this :
 How to make:
Click Label components in the Toolbox and then "picture" object Label1 in Form by
drag-drop. Perform the same steps for object Label2. Text1 object is "image" using
TextBox component, while the object Command1 and Command2 use the Command Button component.


1.2 Setting Object Property
Identify the parts in the Properties window:

 
 Through the Properties Window set the properties of each object as follows:

object
properties
value
Form1
Caption
StartUpPosition
Property test
2-centerScreen
Label1
Caption
Tuliskan nama anda :
Text1
-
-
Label2
Alignment
BackColor
Font
2 – Center
Palette: <putih>
Size : 24
Command1
Caption
Ok
Command2
Caption
Selesai
  
UI so that it becomes like this:

 1.3 Writing Program Code: Property Test
Open the Code window and identify the parts in it :


Windows-based programs are event-driven, meaning that the program works based on events that
occurred on the object in the program. For example, if a user clicks a button
then the program will provide a "reaction" to the click event. The program will provide
"Reaction" in accordance with program codes are created for an event on a particular object.
Select the Command1 object in the Object Selector. Automatically in the Code Editor will
block of code appears following program:

Private Sub Command1_Click ()
end Sub
 

Event Click event is the default (standard) of the Command1 object, you can view other events
at the Event Selector.
In the Code Editor type the code is as follows:
Private Sub Command1_Click ()
Label2.Caption = Text1.Text
end Sub
Private Sub Command2_Click ()
end
end Sub

Save Project1 (file name: Latihan.vbp) and Form1 (file name: Lat1.frm). VB 6 will save
program that you created into several files that are linked, among others: the project file (*. vbp), file
form (*. frm) and module files (*. bas).
Try running Project1 by clicking the Start button on the toolbar or press the
F5 on the keyboard. Type "Salman" in the TextBox and then click the OK button. Then it will appear
the following results:
 
 If you want to exit click the Done button.
Explanation of code:
The following explanation is given how the program works on a simple
Private Sub Command1_Click ()
Label2.Caption = Text1.Text
end Sub

When a user clicks on the OK button (Command1 object) then the contents of the writing on the object Label2 will
together with the contents written in object Text1. Label2 Caption property on the object used to
displays certain text in the object.
Next to exit the program is written the following code:
Private Sub Command2_Click ()
end
end Sub

When a user clicks on the Done button (object Command2) then the program will stop.
End command is used to close the program.
Showing posts is one of the properties owned by the Label component. property contents
writing on label component is Caption, whereas in Textbox is a Text component.
Way of writing (syntax) program code to set an object property is as follows:
nama_object.property = value
Note, after you type a period (dot) nama_object behind the VB 6 will
displays a list of properties and methods that are owned by nama_object:

 This facility is called Intellisense, and really help you to avoid mis-typed nama_object
or her property.
1.4 Modification Program Code
Change the appearance of its UI looks like this:
(Add a Frame component, OptionButton and CheckBox)

 Set additional property objects as follows:

Object
Properties
Text
Frame1
Caption
Pilihan :
Option1
Caption
biru
Option2
Caption
merah
Check1
Caption
tebal
Check2
Caption
miring
 
Frame1 object must be made in advance the form, and thereafter the object Option and Check made ​​in in these Frame1. The purpose of making the various options is to introduce to you facilities and CheckBox Option is used to make a choice in the application. Add the code is as follows:
Private Sub Option1_Click()

Label2.ForeColor = vbBlue

End Sub

Private Sub Option2_Click()

Label2.ForeColor = vbRed

End Sub

Private Sub Check1_Click()

Label2.FontBold = Check1.Value

End Sub

Private Sub Check2_Click()

Label2.FontItalic = Check2.Value

End Sub
Save back to Form1, and then try to run Project1 and see the results:

Jumat, 14 Oktober 2011

What is Visual Basic (VB)

Visual Basic is a computer programming language. Programming languages ​​are the commands understood by the computer to perform specific tasks. Visual Basic programming language, developed by Microsoft since 1991, is the development of its predecessors is the programming language BASIC (Beginner's All-purpose Symbolic Instruction Code) developed in the era of the 1950s. Visual Basic is one of the Development Tool is a tool to make a variety of computer programs, especially those using the Windows operating system. Visual Basic is a computer programming language that supports object (Object Oriented Programming = OOP).


Well, for the first Enable VB 6 via the Start button> Programs> Microsoft Visual Studio 6.0> Microsoft Visual Basic 6.0.
Wait a few moments until the following display appears:

Select Standard EXE and click the Open button. You will see a display of the work area or VB 6 IDE. Identify the major parts in the VB 6 IDE following:

Description:
  • Menubar
  • Toolbar
  • Toolbox : If the Toolbox does not appear click the Toolbox button on the toolbar or go to View> Toolbox.
  • Code Window : If the Code window does not appear click on the View Code button in the Project Explorer or go to View> Code.
  • Project Explorer : If the Project Explorer does not appear click Project Explorer button on the toolbar or go to View> Project Explorer.
  • Window Properties : If the Properties window does not appear click the Properties Window in the toolbar or menu click View> Properties Window
  • Window Form : If the window does not appear click the Form View Object in the Project Explorer or click the View menu> Object. 
In object-based programming (OOP), you need to understand the term objects, properties, methods and events as follows:
  • Object: components inside a program
  • Property: characteristics of object
  • Method: actions that can be done by object
  • Event: events that can be experienced by the object