Anda di halaman 1dari 26

MULAI DENGAN INTERNET

Internet sekarang ada


dimana-mana. Di warnet, di
kantor, bahkan di aplikasi mobile
yang ringkas semacam desknote,
HP, laptop dan lain-lain. Jika
ditanyakan apakah yang
menyebabkan internet sangat
terkenal pasti dijawab dengan
fleksibilitas dan keinstanannya
yang disedikan, memang internet - Setelah itu ketiklah penggalan
dapat menyediakan informasi paragraph berikut pada
yang terkini dan dapat diakses notepad:
melalui berbagai macam broser
yang dapat diakses lintas sistem < HTML >
software. < BODY >
< P > Hari gini tidak mengerti
Hal yang paling penting di internet dan pembuatan
dunia internet dan dapat disebut web/situs < /P >
tulang punggung internet adalah < P > dalam internet anda bisa
situs internet. Jadi pada dasarnya mencari data-data yang anda
pembuatan situs internet sangat inginkan < /P >
penting untuk dipelajari. < P > seperti mencari data
cuaca, geografi, photo grafi,
Software yang mendukung iklim, konflik < /P >
pembuatan situs, dari bawaan < P > anda tinggal klik Internet
windows bisa menggunakan explorer kemudian klik
Notepad kemudian dibuka oleh providernya < /P >
Internet Explorer. Tetapi kalau < P > contohnya seperti
ingin membuat lebih bagus bisa Yahoo.com maka anda akan
menggunakan Microsoft segera < /P >
Frontpage bawaan office 2000, < P > mengetahuinya. < /P >
atau dari macromedia flas, < P > Selain itu anda bisa
Microsoft word, open office. membuat surat dan langgsung
dikirimkan < /P >
Membuat situs dari Notepad- < P > ke tempat tujuan
Internet Explorer. meskipun berbeda alamat dan
- Klik star – all program – komputernya < /P >
accesoris – notepad, seperti < / BODY >
gambar berikut: </HTML>

- Setelah selesai cobalah


simpan penggalan paragraph
itu dengan nama web1.HTML
seperti gambar berikut:

- Setelah itu bukalah internet


Explorer dengan cara klik star

1 Modul Pembuatan WEB


– all program – internet
Explorer seperti gambar
berikut:

- Lebih jauh dengan Internet


Explorer
Anda tinggal klik file kemudian Internet explorer termasuk
open seperti gambar berikut: browser yang popular dan
merupakan bawaan windows.
Untuk mengatur lingkungan kerja
Internet explorer ikuti petunjuk
berikut:
a. klik Tools – Internet option
seperti gambar berikut:

Kemudian anda klik browse, anda


tinggal mencari file web1.HTML
bila sudah mendapatkan anda
tinggal klik ok dan ditampilkan
seperti gambar berikut:

b. Setelah itu ditampilkan menu


dialog seperti gambar berikut:

c. Kemudian klim tab general


kemudian klik home, dari sini
anda dapat menentukan

2 Modul Pembuatan WEB


alamat pertama kali dibuka
oleh Internet explorer anda - Setelah itu klik one web page
bisa merubah menjadi kemudian klik ok seperti
http://www.yahoo.com atau gambar berikut:
http://localhost/index.aspx

- Membuat halaman WEB


menggunakan Microsoft
frontpage
Jika anda menggunakan notepad
untuk menulis home page maka
dibutuhkan waktu lama dan
ketekunan untuk membuatnya,
maka Microsoft windows
memberikan kemudahan untuk - Tunggu beberapa saat sampai
mengakses dimana pada ditampilkan diolog seperti
Microsoft office 2000 dilengkapi gambar berikut:
Microsoft forntpage yang khusus
untuk membuat halaman WEB.
- Untuk membuka MS.
Frontpage anda tinggal klik
star – all program – MS.
Frontpage seperti gambar
berikut:

- Kemudian klik folder – klik


kanan mouse pada
default.htm dan ganti nama
menjadi index.htm dan title
diganti menjadi halaman
pertama seperti gambar
berikut:

- Kemudian masih di folder klik


kanan mouse kemudian klik
- Mulailah membuat web page new page seperti ditampilkan
dengan cara klik file – new – gambar berikut:
web seperti gambar berikut:

3 Modul Pembuatan WEB


- Nama halaman yang - Memasukan object gambar
terbentuk ganti menjadi a. Bukalah file baru
halaman 2 dan halaman 3 b. Kemudian ketiklah data
- Untuk pengetikan tiap berikut:
halaman perhatikan Pilih HandPhone
penggalan paragraph berikut: Samsung SGH-E530
Halaman awal Jaringan : Dual band
Dimensi : 86 x 43 x
Ini halaman muka (Home Page) 26 mm, massa 85 gram
Layar : int: TFT 262.144
Internet merupakan suatu media untuk warna, 176 x 220 pixsel
menambah wawasan anda tentang Exs : OLED 65.536
sesuatu warna, 96 x 96 pixel
Gambar : lihat
untuk kelanjutan paragraf ini anda tinggal
klik hal2 Untuk selanjutnya kerjakan
latihan – latihan berikut ini:
Halaman ke2

Anda tidak lagi disebut kurang gaul 1. Latihan 1


karena tidak mengerti Internet
Welcome to In and Out of the
menuju hal3 Classroom with Microsoft Office
2000 Professional, a practical
Halaman ke3 guide for educators. Microsoft
Office 2000 Professional is a suite
makanya belajar yang tekun siapa tahu of programs that lets you create
anda pinter, gitu loh.. and manage written materials,
publications, data bases,
kembali ke halaman awal spreadsheets, and Web pages for
use with your students or on your
- Setelah selesai mengetiknya own. When you need to create a
jangan lupa menyimpannya. test, make a research
- Buka kembali halaman awal presentation, help students
kemudian kata hal2 diblok collect data, or schedule
kemudian klik kanan mouse resources, Office 2000 gives you
dan pilih hyperlink seperti tools to work more productively.
gambar berikut:
The following are components of
Office 2000 Professional:
• Microsoft Word 2000 provides
everything you and your
students need to produce
professional-looking
documents, communicate
your ideas, and share
information with others.
• Microsoft Excel 2000 makes it
easy for you and your
students to build spreadsheets
and then use, share, and
analyze the data, as well as
provide reports and present
the data graphically.
• Microsoft PowerPoint 2000
allows you to organize,
illustrate, and present your
ideas in a multimedia
presentation. It gives you the

4 Modul Pembuatan WEB


tools to communicate with create professional reports with
impact, whether in the customized layout and graphics.
classroom, to parents, or to
colleagues. New Web features in Access 2000
also enable you and your
• Microsoft Outlook 2000 students to collaborate on
provides an integrated projects. Using the built-in
desktop for you and your features of Access 2000, you can
students to use to contact display information from the
other students, parents, and database on the Web and
colleagues and to organize students can input data into a
and manage your e-mail database from the Web. In fact,
correspondence, calendar, students can build a database
contacts, and tasks. collaboratively with students all
• Microsoft Access 2000 lets you over the country using Data
develop and use databases to Access Pages.
store, manipulate, and share
information. When you are finished with this
lesson you will have a database
• Microsoft Publisher 2000 helps to store census information. In
you create eye-catching the process you will learn to:
newsletters, flyers, brochures,
programs, and Web sites. • Use the Table Design Wizard.
Publisher 2000 complements
writing and learning activities • Add Fields to the Table.
in your classroom and can
help you expand the visibility • Add Data to the Table.
of school events and activities.
• Use a Form to view and add
Microsoft Office 2000 Professional data to your table.
is the exciting new productivity
suite that makes the Web work • Query a database for specific
for students and educators to information.
enhance learning and increase
productivity. In today's • Customize a report on data in
classrooms, doing research, a database.
collecting data, collaborating with
peers, compiling results, and • Create a Data Access Page to
synthesizing information into view and share database
interactive presentations are information on the Web.
activities important to increasing
critical thinking skills. With new
tools to enhance collaboration r 2000
and information access, Office
2000 is the right tool for the Access 2000 has several new and
classroom and the administrative improved features that make it
office. even easier to view and share
information from a database.
2. Latihan 2 These features include:

• Improved wizards. The wizards


Whether you want to organize help you create tables, forms,
your educational records, and queries and are even
maintain departmental more intuitive to use.
information, or coordinate class
projects, an Access 2000 • Name AutoCorrect. When you
database provides the structure rename a field (column) in a
and flexibility you need. You can table, the change is
store all kinds of information in automatically updated in all
an Access 2000 database, use dependent tables, queries,
queries to analyze the data, and and forms.

5 Modul Pembuatan WEB


• Drag and Drop to Excel. You
can export data from Access
2000 to Excel 2000 simply by
dragging the Access 2000
objects into Excel 2000
(tables, queries, and so on).
This feature is convenient
when you maintain
information on your students
in both Access 2000 and Excel
2000 and you need to transfer
some data from one file to
another.

• Compact on close. Databases


can grow in size quickly and
take up space on your hard
disk. Access 2000
automatically compresses a
database when the file is
closed to reduce the file size.
This is especially useful when
space on the hard disk is
limited and you are storing
databases for a number of
classes.

• Report snapshot. You can


create snapshots of Access
2000 reports that can be
distributed to a disk, printer,
Web page, or e-mail.

• Data access pages. Creating


Web pages from the objects in
your database is a simple
process using this new feature
in Access 2000. Now your
students can view and add
information to a class
database easily from your
school intranet or from home.

6 Modul Pembuatan WEB


• Reports. Use reports to deliver
a professional presentation or
0 written report to your class.

To use Access 2000 effectively, • Queries. Filter data so that you


you should be familiar with the retrieve selected records or
structure of a database. A fields from the database.
database consists of a collection
of tables, queries, forms, reports, • Pages. Create HTML pages
and pages that you use to from a database quickly and
manage and present data. These efficiently.
components are also called
• Macros. Automate tasks
database objects. When you build
that you perform on a
a database, you create as many
regular basis in a database.
of these objects as you need and
Access 2000 stores them in one • Modules. Automate a group
database file. Each object you of related procedures in
create in the database is Access 2000.
dependent on other objects. That
is, a query, form, or report draws You create and open database
information from tables, so objects from the Access 2000
changing data in any one of database window, which lists the
these objects changes the data in objects in the left pane of the
all of these objects. Because the window. When you click on one of
objects in a database are related the first five items, the right pane
to one another, building a gives options for creating the
database requires careful object, and it shows all existing
planning. objects of that type in the
database. You can open an object
In fact, it only makes sense to by double-clicking it.
build a database when you need
a flexible system for organizing In this chapter, you first learn
and analyzing data. For example, about tables in Access 2000.
when you are teaching three Later, you learn about forms,
sections of one subject and you queries, reports, and pages.
want to grade all three classes on Macros and modules are features
one curve, it makes sense to for advanced Access 2000 users.
store your records in a database You can learn more about them
instead of in an Excel 2000 with the help of the Office
workbook. You can store Assistant after you are familiar
information on each class in with the objects in a database. up
separate tables and connect a database
them by a common field. Then
you can use a query to analyze To get started with Access 2000,
student performance in all three you can create a database for a
classes. class project to conduct a census.
Students can gather information
There are seven main from interviews and store it in a
components of a database in database, then compare the
Access 2000: results with city census results
from the past four decades. They
• Tables. Use tables to store can use Access 2000 queries to
database information. analyze how demographics vary
in different neighborhoods and
• Forms. Use forms to enter or
how they have changed over
edit the information in your
time.
tables. Forms let you view one
record at a time. To create a database

1. Start Access 2000.

7 Modul Pembuatan WEB


2. In the Microsoft Access dialog Use Datasheet view when you
box, select Blank Access 2000 want to view, add, or delete data
database and click OK. from a table. You can also
reformat your table to change the
3. In the File New Database size and order of the field
window, decide where you columns in this view.
want to store the database on
your computer and name the Datasheet view
database Student Census.
Design view
4. Click Create.

When you click Create, the Use Design view when you want
Student Census database to change the structure of a
opens. You can now create and table. You can add or delete
store tables, forms, reports, fields, change a field caption or
and queries in the census size, or select the type of data
database. you plan to enter into a field in
Design view.
The first object to add to your
database is a table. You use Creating tables
tables to store all the data in the
database. Each row of a table When you open a database, you
contains one record. Records are see three options for creating a
made up of fields that contain a table:
particular piece of data in the
table. For example, when you • Create table in Design view
create the census database, all
the data for one household will • Create table by using wizard
be stored in a record. One field in
the table might specify the • Create table by entering data
number of people in the
Unless you are already familiar
household or the neighborhood
with Access 2000, you should use
where the household is located.
the Table Wizard when you create
Every table in Access 2000 must tables.
have a field that uniquely
The Table Wizard helps you to
identifies each record in the
organize data by providing
table. This field is called the
sample fields that you can
primary key. You can recognize
include in a table and it assigns a
the primary key in a table by the
primary key to each record.
ID appended to it. The primary
Later, if you need to change the
key ensures that you can retrieve
design of your table, you can
data accurately and efficiently
modify it using Design view. The
when you pull information from
Table Wizard even provides a
the database. Access 2000
sample student table that you
automatically assigns a primary
may want to build after you have
key to each of your records for
finished designing the census
you when you use an Access
database.
2000 Table Wizard.
To create a table using the
Viewing tables
Table Wizard

There are two ways to view your 1. From the objects box in the
table: Datasheet view and Design Student Census database
view. When you double-click a window, click Tables.
table object from the Access
2000 database window, it opens 2. Double-click Create table by
in Datasheet view. using wizard. The Table Wizard
dialog box opens.

8 Modul Pembuatan WEB


3. Click each of the tables in the • To move one field to the left,
Sample Tables list and scroll press SHIFT+TAB or use the
through the Sample Fields list. left arrow key.

4. When you see a field that you • To move to the first field of the
want to include in your table, active record, press HOME.
click it and then click the
single right arrow next to the • To move to the last field of the
Sample Fields list. If you want active record, press END.
to include all of the Sample
Fields in one table, simply click To move from record to record
the double right arrow.
• To move to the next record,
5. If you accidentally add a field click the single right arrow
that you don’t want or add the next to Record.
same field twice, click it in the
Fields in my new table list and • To move to the previous
then click the single left arrow record, click the single left
to remove it. arrow next to Record.

6. When you are satisfied with • To move to the first or last


the fields in the table, click record in the table, click the
Next. If you need to later, you First Record or Last Record
can modify the fields in the icon next to Record.
table using Design view.
• To move one window down,
7. The Table Wizard provides a press PAGE DOWN.
name for the table. Replace
• To move one window up, press
this name by typing Census
PAGE UP.
Table.
Changing a table in Design
8. Make sure the option for the
view
Table Wizard to assign a
primary key is selected and
then click Next. When you use the Access 2000
Table Wizard, chances are that
9. Click Finish to exit the Table you will not be able to design the
Wizard. table exactly as you like it. In the
census, for example, you may
The census table appears in want to include information on
Datasheet view. ethnicity and income, two fields
that are not available from the
Navigating in the table Table Wizard Sample Fields list.

Before you enter data into a To modify a table, you must open
table, you need to know how to it in Design view by selecting the
move around in it. Depending on table you want to modify from
what you want to do, you can use the main window of Access 2000
the TAB key, the navigation and then clicking Design, or if the
buttons at the bottom of the table is already open, click the
table, the arrow keys, or the Design icon in the left corner of
HOME, END, PAGE UP, and PAGE the table window.
DOWN keys.
To add a field to a table
To move within a record
1. Open the table in Design view.
• To select any field, click it.
2. Click in the first empty row of
• To move one field to the right, the Field Name column.
press TAB or use the right
arrow key.

9 Modul Pembuatan WEB


3. Type the field name. Press the • Currency. Numbers and
DOWN ARROW to move to the monetary symbols. You can
next empty row if you want to only add numbers to a field
add another field. A data type with a currency data type.
will automatically be assigned
to the field (which you can • Date/Time. The date and the
change later). time in 12- hour and 24- hour
formats.
4. If the fields are in the wrong
order, you can click to select a • Yes/No. A single value that
field and then drag it to where indicates yes or no, true or
you want it to appear. false.

5. When you have finished For information on the other data


adding fields, save and close types, ask the Office Assistant.
the table.
Each field in an Access 2000
To delete a field from the table, table must be assigned a data
select the entire row by clicking type. The fields you select from
the leftmost box and then press the Table Wizard already have a
the DELETE key. data type assigned to them. Text
is the default data type for any
To rename a field to your fields you add to your table.
table
To set a data type
1. Open the table in Design view.
1. Open the table in Design view.
2. Select the row containing the
field name you want to change 2. Click in the data type column
by clicking it. of the field for which you want
to set a data type.
3. Type the new field name in the
Caption box under Field 3. Click the arrow in the data
Properties. type text box to see the drop-
down list of data types.
4. Save and close your table.
4. Select the data type you want
With the new AutoCorrect from the drop-down list.
feature, the field name change is
automatically updated in all 5. Save and close the table.
queries, forms, reports, and
pages that draw information from Setting field properties
the table you have modified.
Each field in a table is defined by
Setting a data type a set of properties. These
properties determine the size of
The data type determines the the field, how it is formatted, and
kind of data that can be entered what it is called, among other
into a field. It also formats the things. You can view or change
value you enter for the data type. field properties in Design view.
For example, when you enter
numbers in a field with a To set field properties
currency data type, the dollar
and decimal signs will be 1. Open the table in Design view.
automatically added to the
2. Select the field for which you
numbers. Some of the more
want to set properties.
common data types are:
3. Click the General tab in the
• Text. Any combination of
Field Properties window.
letters and numbers.

10 Modul Pembuatan WEB


4. Click the property you want to You may add a field to your
modify and type the census table and later discover
appropriate text. Do one or that you cannot collect data for
more of the following: that field, so you need to delete it
from your table. Deleting fields
• Type a number in the Field and records in Access 2000 is
Size box to indicate the simple:
maximum number of
characters that field can hold. • To delete an entire record,
make sure you are in
• Select Y or N in the Required Datasheet view and click the
box to indicate whether data record selector in the box at
must be entered in this field the left of the record and then
for every record. press the DELETE key. Then
click Yes.
• Type the caption you want for
a field in the Caption box. This • To delete an entire field
caption appears on the tables from a table, go back to
and forms. If you do not enter Design view and click the
a caption, the field name field header so that the
appears as the caption. whole row is selected and
then press the DELETE key.
5. After you have set the field
properties, save and close Sorting records
your table.
Access 2000 displays the
To add data to a table
information in a table in
1. Open the table in Datasheet alphabetical or numerical
view. order based on the primary
key. However, you can sort
Press TAB to move from the information so that it appears
primary key column to the in an order that works better
second column in the table. (You for you. For example, if you
cannot add data to the primary want to group people by
key column. Access 2000 educational level in the census
automatically generates the table, you can select that field
information in this column.) and then click one of the sort
buttons. Access 2000
2. Type data in the second alphabetizes the records
column. As soon as you enter according to the data in that
a value into the second field.
column, Access 2000
automatically numbers the To sort records
first record and adds another
record to the table. 1. In Datasheet view, click the
header of the field to sort by
3. Press TAB to move to the next so that the whole column is
column in the table, and type selected.
your data. Unless a field is
required, you can leave a field 2. Click the Sort Ascending
empty. button or the Sort
Descending button on the
4. When you reach the end of the Datasheet toolbar.
first record, press TAB to move
to the next record in the table. 3. Save and close the file.

5. Save and close your table. You can use the sort feature for
query results also.
Deleting data from a table
xploring forms

11 Modul Pembuatan WEB


Forms make it easy for you and 7. Enter a name for the form you
your students to access have created, then select
information in a database. With a Open the form to view or enter
form, you can focus on one information, and then click
record in a database at a time, Finish.
and you can view, add, and
delete data from that record. In To open a form stored in the
addition, you can customize a database, double-click it in the
form to view and print main database window.
information in a style you like.
You can create a simple multi-
3. Latihan 3
page form that looks like this:

Writing Your First Application
• Starting Visual Basic
Creating forms • Building the Calendar Feature
• Adding a Clock Feature
The easiest way to build a form is • Configuring the Timer Control
by using the Form Wizard. The • Using the Label Control to
Form Wizard lets you choose the Display the Time
layout of records in the form and • Adding a Message
also the background, color, and • Improving Your First Application
format of the display. The Form
Wizard lets you preview the Who is the end user?
layout and style options when
you create a form. An end user is the person for whom the
program was made--the person who uses
To create a form the program.
1. From the list of objects in the
census database window, click
Forms. Writing Your First Application
2. Double-click Create form by
using wizard. The best way to learn programming is to
do programming. Therefore, let's create a
3. Under Tables/Queries, select program. Your first program will be a
the table the form will be Visual Basic Calendar, which allows the
based on from the drop-down end user to
list.
• View a calendar of the present
4. Select the fields that you want month
to appear in the form by • Browse months
clicking each one and then • View a clock that presents the
clicking the arrow that current time
appears to the right of the
Available Fields list. If you • Read a secret message
want all the fields from the
table to appear in the form, If you think that this is too much
click the double arrow and functionality to implement for a
then click Next. beginner's program, don't worry; it's not.
Visual Basic does most of the work for
5. Select the layout for your form
you. Unlike other languages, such as C++,
by clicking Columnar, Tabular,
where you have to program every little
or Datasheet and then click
thing, Visual Basic brings a high degree of
Next.
automatic programming to your
6. Select the style of the fingertips. Thus, you can do a lot with not
background print you prefer a lot of code.
and then click Next.
However, don't misinterpret "not a lot of
code" to mean "not a lot of power." Visual

12 Modul Pembuatan WEB


Basic is a very powerful language. You can retrieve the finished code from the
can write Visual Basic code that does Web site dedicated to this book
"every little thing" if you want or need it (http://www.mcp.com/info). You'll be
to. You also can exploit the labor-saving asked to enter an ISBN; you need to enter
nature of VB to implement a program 078971633x, and then click the Search
quickly. The choice is yours. Visual Basic button to go to the Book Info page for
is versatile enough to be useful to a broad Using Visual Basic 6. After you download
range of programmers--from beginner to the code, double-click the file
seasoned professional. Project1.vbp for the Chapter 1 code. If
you've installed Visual Basic on your
Starting Visual Basic system, double-clicking invokes the
sample project within VB.
The first thing you need to do is open a
Visual Basic program. From the Windows Get the calendar program into the
Start menu, choose Programs, Microsoft Visual Basic IDE
Visual Studio 6.0, and then Microsoft
Visual Basic 6.0. 1. From the Project menu, choose
Components (see Figure 1.2).
When you start VB, you're taken to the
Visual Basic Integrated Development FIGURE 1.2 All the ActiveX Controls
Environment (IDE). This is your that come with VB aren't automatically
programming workbench, the place where loaded by default. You have to select some
you create your programs (see Figure 1.1). from the Components menu.
Notice that the IDE presents what looks
like an empty window containing some 2. In the Components dialog,
dots and a title bar with the word Form1. select Windows Common
This window is a form, the primary Controls 2-6.0 and click OK (see
building block of a Visual Basic Figure 1.3).
application. An application can have many
forms or one form; the application we're FIGURE 1.3 Visual Basic comes with
developing for this example has one form. many ActiveX components that you can
use in your projects. Some need to be
FIGURE 1.1 The Visual Basic Integrated added to the IDE.
Development Environment presents a
unified programming work area. What is ActiveX?

ActiveX is a brand name from Microsoft


ActiveX controls that lets you create little programs,
formally known as components and
Another name for the little programs that controls, that you can add to larger
come with Visual Basic is ActiveX programs. These larger programs that you
controls. The calendar program that you can add ActiveX components and controls
add to your application is an ActiveX to can be standalone programs or
control. programs that run on the Internet. You can
use Visual Basic to make your own
ActiveX components and controls.

Building the Calendar Feature


These steps added the calendar control to
Now let's build the features of your the Visual Basic ToolBox. The formal
application. First, you need a calendar. name for the control that you've inserted
You could build one from scratch, or you into your first application is the
could add the calendar program that MonthView ActiveX control. We'll use
comes within VB to your application. this terminology from here on.
Let's use the one that comes with VB (if
you don't have a few years to learn VB at Now you need to add the control to the
the expert level, it makes the most sense). form.

If you don't want to create the Visual Add the MonthView control to your
Basic Calendar program from scratch, you form

13 Modul Pembuatan WEB


1. Select the MonthView control Measuring a second with the Timer
icon from the Visual Basic
ToolBox (see Figure 1.4). You set the increment of time measured
2. Double-click the MonthView by the Timer by using the Interval
control icon to add the control to property. The Timer measures time in
the main form (see Figure 1.5). intervals of 1/1000 of a second. Therefore,
to measure time in half-second intervals,
FIGURE 1.4 When you add an ActiveX set the value of the Interval property to
Control from the Components dialog, it 500.
appears in the Visual Basic ToolBox.

FIGURE 1.5 When you add an ActiveX Setting the value of the Timer's Interval
Control to a form, the control sets itself at property to 500 is operationally the same
its default size. as configuring the Timer to do something
every half a second. Now you have to
You've just created your first program. program what you want the Timer to do
Press F5 or choose Start from the Run every half second: to report the current
menu to run it . Click the End button or time. You need a place in which to display
choose End from the Run menu to the time. For this, use a Label control.
terminate the program.
Using the Label Control to Display
Adding a Clock Feature the Time
The next feature to implement into your Add a Label control to the form
practice program is the capability to
display the time. You'll use the Timer 1. Select the Label control icon in
ActiveX control, which is intrinsic, the ToolBox.
meaning that it's standard to Visual Basic 2. Rather than double-click, draw
(built right into the core code). You never a box on Form1 by dragging the
have to add it to the ToolBox; the Timer is mouse (see Figure 1.10).
always there (see Figure 1.6) Look at
Table 1.1 to see the ToolBox icons and FIGURE 1.10 You also can add a control
their associated ActiveX control. to a form by selecting the control in the
ToolBox and dragging to size.
FIGURE 1.6 The Timer is a Visual Basic
intrinsic control. runtime as windowless 3. In the Properties window, scroll
controls; they aren't. You never see a to the BorderStyle property. Click
windowless control at runtime. the property and then select 1-
Fixed Single from the drop-down
list (see Figure 1.11).
Configuring the Timer Control
FIGURE 1.11 Some properties, such as
Although you've added the Timer to the the Label control's BorderStyle property,
form, it won't really do anything until you have values that you can set from drop-
configure it to report time the way you down menus.
want it to.
What's an event procedure?
Configure the Timer to report the time
An event procedure is a piece of code that
1. Select the Timer control on the you write to execute a programming
form. (Make sure that the Pointer event. For example, when a user clicks a
is selected in the ToolBox.) CommandButton, a Click() event is
2. In the Properties window, select generated. Visual Basic provides a
the Interval property and enter the CommandButton_Click() event procedure
number 500 (see Figure 1.9). that you can program to react to the
CommandButton click. The same is true
FIGURE 1.9 The Properties window is with the Timer. When a Timer's interval is
where you configure the settings for a reached, a Timer() event is fired. You can
selected ActiveX control. think of the code that you write in the
Timer() event as "do this when the Timer's

14 Modul Pembuatan WEB


interval has been reached." Some controls a number. For example, the default value
have many events; some have only a few. of the CommandButton's Name property
It depends on the control. You can learn is Command1. If the value Command1 is
more about event procedures in Chapter 6, already in use, VB names the new
"Working with Properties, Methods, and CommandButton Command2 (and so on).
Events." You can change the default value of a
control's Name property only at design
time. Also, the Name property of the
Code the instructions that display the control isn't something that end users see
time in the Label control when the program is running.

1. Double-click the Timer control Using listing code


on the form. The Code window
appears. If you don't want to type code from the
2. Add the following line of code book into your programs, you can use the
to the Timer1_Timer() event code in the file referenced in the heading
procedure in the blank space of the listing. You can get this code from
between the line Private Sub the book's Web site (http://
Timer1_Timer() and End Sub (see www.mcp.com/info). To access this code,
Figure 1.12): open the file in a text editor such as
Label1.Caption = Time Notepad. Then Copy and Paste the code
3. Run the code by pressing F5 from the text editor into VB.
(see Figure 1.13).
3. Use the drag technique in Step 2
Adding a Message to add a TextBox above the
CommandButton.
For this program, a message appears when 4. Double-click the
you click the CommandButton on the CommandButton to expose the
form. To implement this feature, first you Click() event procedure.
must add a CommandButton to the form. 5. Add the code in Listing 1.1 to
the Command1_Click() event
Add a CommandButton procedure (see Figure 1.15).
1. Select the CommandButton LISTING 1.1 01LIST01.TXT--
control in the ToolBox.
2. Add a CommandButton to the
The Code that displays a secret
form by dragging your mouse message in the
cursor across the form (see Figure TextBox
1.14). 01 Dim strMsg As String
02 strMsg =
WeekdayName(Weekday(Date), _
FIGURE 1.12 The Timer event procedure False, vbUseSystemDayOfWeek)
is fired every time its Interval is reached. 03 strMsg = strMsg & " is the
If you set the value of the Interval first day of the rest"
property to 500, the Timer event is fired 04 strMsg = strMsg & " of your
life!"
every half second. 05 Text1.Text = strMsg
6. In the Properties window, set
FIGURE 1.13 The Timer assigns the
the Caption property for the
present time to the Caption property of
Command1 CommandButton to
the Label control in its Timer() event
Click for a Secret (see Figure
procedure.
1.16).
FIGURE 1.14 Add a control by dragging
FIGURE 1.15 Notice that the code for
if you want to custom-size it at a specific
the Command1_Click() event procedure
location.
doesn't have line numbers, which are used
in this book for reference purposes. You
A control's Name property shouldn't use them in code.
All controls have a unique name. By FIGURE 1.16 When you change the
default, VB assigns the value of the Name value of the CommandButton's Caption
property to be the control's type name plus

15 Modul Pembuatan WEB


property, you change the text that the Make the clock more readable
CommandButton displays within itself.
1. Press Shift+F7 to view the
Saving projects Object window.
2. Select the Label control in the
When you save a project, you should main form.
create a directory to hold all the parts of 3. In the Property window, scroll
the project--project file (.prj) and forms down to the Font property.
(.frm and .frx). FRX files contain 4. Click the ... button to the right
information about embedded graphics in a of the Font property (see Figure
form. 1.19).
5. Select the Bold Font Style from
7. Save the code by selecting Save the Font dialog (see Figure 1.20).
Project from the File menu.
8. Run the code by pressing the F5 FIGURE 1.19 Clicking an ... button
key (see Figure 1.17). opens a Property dialog.

The code in Listing 1.1 shows you how to FIGURE 1.20 The Font dialog appears
work with variables. You can think of a when you need to change the Font
variable as a storage container for property of any control.
unknown information that's to be provided
at a later time or at another place in code. Improve the TextBox
Line 1 of Listing 1.1 shows you how to
declare a variable by using the Dim 1. Select the TextBox.
keyword as shown in Line 1. Line 1 2. Scroll down the Properties
creates the variable strMsg. window to the MultiLine
property. Set it to True as shown
When you create a variable, it doesn't in Figure 1.21.
contain any data. To give the variable 3. Keep scrolling down the
some value, you must assign some data to TextBox properties to the
it. Lines 2 through 4 of Listing 1.1 assign ScrollBars property. Set it to 2-
value to the strMsg variable by Vertical (see Figure 1.22).
continually adding new data to existing
data. Finally in Line 5, the information FIGURE 1.21 Set the MultiLine property
stored in the variable strMsg is assigned to True to make the text in the TextBox
to be the value for the Text property of the wrap.
Text1 TextBox.
FIGURE 1.22 If you set ScrollBars to 2-
FIGURE 1.17 Click the CommandButton Vertical, up/down scrollbars appear. 3-
to fire the Click() event procedure that Horizontal show sideways scrollbars, and
displays the secret message in the 4-Both show scroll bars both ways.
TextBox.
4. Scroll to the Text property and
For more information on variables, what delete the text Text1 from the
they are, and how to use them, see drop-down list (highlight it and
Chapter 7, "Using Data Types, Constants, press Delete).
and Variables." 5. Increase the vertical size of the
TextBox a small amount to
Improving Your First Application accommodate the capability to
display multiple lines of text.
As you review the work that you've done
so far, notice that some things need Restrict resizing and assign a title to the
improvement. Figure 1.18 shows these form
shortcomings.
1. Click the form. Be careful not to
FIGURE 1.18 The upper form is the state click any ActiveX control on the
of your program before the user clicks the form; otherwise, you'll get the
CommandButton. The lower form is after properties for the control rather
the user clicks the CommandButton. than the form in the Properties
window.

16 Modul Pembuatan WEB


2. Select the BorderStyle property o Adding Excitement with
and set it to 3-Fixed Dialog (see the New Graphical
Figure 1.23). Enhancements
• Working with the New Controls
FIGURE 1.23 Setting the BorderStyle o Selecting Dates with the
property to 3-Fixed Dialog makes it so MonthView and
that the form can't be resized. Also, only DateTimePicker Controls
the Close (¥) button is shown in the title o Making Movable Toolbars
bar. with the CoolBar
o Using Graphics with an
3. In the Properties window, set ImageCombo
the form's Caption property to o The FlatScrollBar Control
First App. • Working with the New Language
4. Save your work by choosing Features
Save Project from the File menu. o File System Objects
Then run the code by pressing F5 o New String Functions
(see Figure 1.24). o True Dynamic Control
Creation
FIGURE 1.24 Your first application lets • Learning About VB and the
you view months and the present time, as Internet
well as display a secret message that • Finding Out About the New Data
users can view by scrolling through a Capabilities
TextBox. • New Object Programming
Additions
Congratulations! You've made a very
powerful program in Visual Basic by
using the tools and building blocks that
the language provides. Granted, a lot is
Getting a Quick Overview of VB6
going on behind the scenes that we might
have covered in more detail, but you'll get If you're new to Visual Basic, the title of
more in-depth coverage in the following this chapter might be a little confusing.
chapters. Clearly if you are a novice to the
language, everything about VB is new.
For more information about the intrinsic Even so, you shouldn't avoid this chapter.
controls that come with VB, read Chapter There's something in it for you,
4, "Using the Intrinsic Controls." To learn particularly in the sections focusing on the
how to get around the VB IDE, read new ActiveX controls. For those of you
Chapter 3, "Working in the Visual Basic 6 who have done some work in other
Programming Environment." To get a versions of Visual Basic, you'll find this
clear understanding of properties, chapter very relevant.
methods, and events, and how they relate
to Visual Basic programming, read What's Omitted
Chapter 6, "Working with Properties,
Methods, and Events." Finally to get an Keep in mind that some new features in
in-depth view of the Timer control, read VB6 have been omitted from this
Chapter 16, "Working with Time and discussion. These features require more
Timers." than an introductory knowledge to fully
understand them. Many of these features
that weren't discussed, however, are
4. Latihan 1 covered in later chapters, whereas others
are described in the documentation that
comes with the product.
What's New with Visual Basic
6 Saying that Visual Basic 6 has some
interesting new features is nothing short
• Getting a Quick Overview of VB6 of an understatement. Visual Basic 6 has
• Getting More Power from so many amazing new features that
Enhanced Controls overstatement is next to impossible
o The Validate Event and the because so much is new in so many areas.
CausesValidation Property New controls allow your applications to

17 Modul Pembuatan WEB


incorporate the look, feel, and function of likely would program the TextBox's
Office 97 applications and Internet LostFocus event handler to see if, indeed,
Explorer. No more do you have to have at the user entered correct data. If they
least one instance of a control on your hadn't, you could invoke the control's
form to create controls on-the-fly. With SetFocus method in which validation was
VB6, you add controls to your project occurring to keep the user from
dynamically with only code, and you can proceeding. Sometimes the logic of this
make custom ActiveX controls leaner and programming could cause your users
meaner than ever. You can even write problems. If they never entered the right
server-side applications that use Dynamic data, they would be locked into that one
HTML embedded with Internet control--they couldn't even click a Help
Information Server DLLs. button. The new Validate event procedure
and the CausesValidation property address
This chapter gives some new features a bit this issue.
more attention than others. Some new
improvements involve working with Listing 2.1 shows how to use the Validate
larger-scale data access programs that event procedure to check a TextBox's
might involve hundreds--if not data. The code relates to the illustration in
thousands--of users on a corporate Figure 2.1. If users don't type the word
network or on the Internet. These types of Cherries in the first TextBox, they can't
Visual Basic applications, known as proceed to the second TextBox. However,
enterprise applications, are usually written because the value CausesValidation
with the Enterprise Edition of VB. These property of the CommandButton is set to
new enterprise features are referenced False, users can click it to help determine
here but fall outside the scope of this the right word to enter.
book.
Using the CausesValidation property
Working with the Windows common
controls Notice the Cancel parameter on Line 1.
Visual Basic provides this parameter
Most controls discussed in this chapter are within the control's Validate event
not intrinsic (standard) ActiveX controls. procedure. If you set the value of Cancel
Therefore, they must be added to your to True (Line 7), the program's focus
project from the Components dialog won't be allowed to leave the control
(choose Components from the Project except to go to other controls that have
menu). When you open the Components their CausesValidation property set to
dialog, select Microsoft Windows False.
Common Controls, Microsoft Windows
Common Controls-2, and Microsoft
Windows Common Controls-3 from the LISTING 2.1 02LIST01.TXT--
list. Allowing Some Controls Event
Handling Activity
Getting More Power from During Data Validation
01 Private Sub
Enhanced Controls Text1_Validate(Cancel As Boolean)
02 `Make it so that if the user
Before we look at the completely new does not
03 `enter the word, "Cherries" in
additions to VB6, let's look at some
the TextBox
enhancements to the features from the 04 `the cursor will be returned
previous version. this TextBox
05 If Text1.Text <> "Cherries"
The Validate Event and the Then
06 MsgBox "You cannot go on!"
CausesValidation Property 07 Cancel = True
08 End If
The first enhancement that affects just 09 End Sub
about all intrinsic ActiveX controls is the 10 Private Sub Command1_Click()
11 Dim strMsg As String
addition of the Validate event and the 12 Dim strQuote As String
CausesValidation property. Before VB6, if 13 strQuote = """"
you had to check to see if a word was 14 `Make an instructional message
typed properly in a TextBox, you most

18 Modul Pembuatan WEB


15 strMsg = "You must type the context, download the file VB6Ch2.zip
word," & strQuote
and look at the project prjListView.vbp.)
16 strMsg = strMsg & "Cherries" &
strQuote & " "
17 strMsg = strMsg & "in the first Getting files From the Web site
TextBox."
18 MsgBox strMsg, vbInformation,
"Instructions"
The files referenced in this book can be
19 `The reason that you can click downloaded from the Web site dedicated
on this to this book. The source code can be
20 `CommandButton even though the found at http://www.mcp. com/info. When
Cancel parameter you get the URL, enter 078971633x, and
21 `of the Validate event handler
is set to True then click the Search button to go to the
22 `is because the value of Book Info page.
CauseValidation
23 `property of this CommandButton
is set to false.
24 End Sub FIGURE 2.2 You now can have a
background graphic in the ListView
Commenting code
control client area.
The apostrophe (`) before a line of code
Figure 2.3 shows you the new TabStrip
denotes a commented line. That line of
control, which now allows you to place
code isn't run by Visual Basic.
graphics in each tab. The control also has
a new property, HotTracking, that you can
assign at design time. If you set the value
FIGURE 2.1 The Validate event of HotTracking to True, the tab highlights
procedure allows you to check for correct when you pass the mouse pointer over it.
data while still allowing you to access As mentioned earlier, as with all the new
other controls during the validation controls, the TabStrip control has a
process. Validate event procedure. (The example
code for this control is in project
Adding Excitement with the New prjTabStrip.vbp, in the VB98Ch2.zip file
Graphical Enhancements on the book's Web site.)

Visual Basic, as always, allows you to use FIGURE 2.3 The TabStrip control has
graphics to make your programs come been enhanced to allow for icons on each
alive, and Microsoft has enhanced the tab.
graphical capabilities of many controls.
First, the ImageList control now supports The Slider control has a new property,
.gif files. This enhancement is substantial Text. When you set a string to the value of
because just about every control that uses the Text property, that string appears
graphics has an ImageList control within a ToolTip window. The position of
associated with it. the ToolTip window is determined by the
Slider control's new TextPosition property
The ListView and TabStrip controls have (see Figure 2.4). To see this code in
been enhanced to allow you to use action, review the project prjSlider.vbp
pictures and icons for decoration and from the book's Web site.
description. Figure 2.2 shows you the new
ListView control, to which you can add a FIGURE 2.4 The Slider control now has
background picture in the client area. The a Text property that shows you a ToolTip
background picture can be centered, tiled, window.
or placed at any corner. You can add
check boxes to ListItems child objects Many enhancements have been made to
within the control by setting the the ToolBar control. You can now add
ListView's CheckBoxes property to True. drop-down menus to the toolbar by using
Also, you can make the scrollbars of the a ButtonMenu. The Style property
ListView appear in the new flat style by supports a transparent setting
setting the FlatScrollBars property to (tbrTransparent) that allows you to have
True. (If you want to see some of the the buttons on your toolbar appear and
ListView control enhancements behave like the buttons on the Internet
demonstrated within a programming Explorer toolbar. Figure 2.5 shows the
effect of the new transparent setting and a

19 Modul Pembuatan WEB


collection of buttons with each button Making Movable Toolbars with the
having its own ButtonMenu. If you want CoolBar
to find out how to set up your toolbar as
shown in the figure, download the project The new CoolBar control is similar to the
prjToolBar.vbp from the book's Web site. Coolbars you've been using in Office 97
Open the project, select the form, and then and Internet Explorer. A CoolBar is a
right-click the ToolBar control to view the toolbar that you can move on a form, and
property page for the control. You then the CoolBar control is a container for
can review the various settings for the other ActiveX controls. Thus, you can
control. offer your users more flexibility and
utility by embedding other controls within
FIGURE 2.5 The ToolBar control is the CoolBar. Figure 2.6 shows a CoolBar
enhanced to provide ButtonsMenus and with three Band objects. The first Band
hotspots. The control's property page contains two OptionButtons, the second
allows you to configure a ToolBar at a contains a ToolBar control with three
very detailed level. buttons, and the third band contains a
ComboBox control. At runtime you can
Working with the New Controls move the Bands around the Coolbar's
client area any way you want.
Visual Basic 6 ships with many new
ActiveX controls. Some of these controls CoolBar bands
apply to stand-alone desktop programs;
others pertain to enterprise-wide data A band is a bar within a CoolBar. A
access development projects. In the CoolBar can have many bands that can be
following sections, you'll see the new moved about in the CoolBar client area.
controls that relate to your desktop
development efforts.
Using Graphics with an
Selecting Dates with the MonthView ImageCombo
and DateTimePicker Controls Working with ImageLists
VB6 has two controls that provide you An ImageList is a "windowless" control
with a new way to view and select dates: that you use to store different types of
MonthView and DateTimePicker. What's graphics: bitmaps, gifs, icons, and so on.
interesting about these controls is that You associate an ImageList with a control
they let you view and select dates within by assigning the ImageList in question to
the context of a calendar. The MonthView a control's ImageList property. For
control presents a full calendar that you example, to assign an ImageList named
can traverse from day to day or month to ImageList1 to an ImageCombo, the code
month. The DateTimePicker control is is ImageList1.ImageList = ImageList1.
similar to the MonthView except that its
calendar drops down when the user clicks
the control's down arrow. Figure 2.6
The ImageCombo control, new with
shows you the Using all the new controls
Visual Basic 6, allows you to embed
graphics within a ComboBox. To
All the controls discussed in this section accomplish this, Visual Basic introduces a
are displayed and used within a single new object, the ComboItem, which
project, WhatsNew.vbp. You can encapsulates all layout and data properties
download this code from http:// that are needed to work with an
www.mcp.com/info, as explained ImageCombo. A ComboItem has a Text
earlier.MonthView and DateTimePicker property for string display of a line within
controls. the ImageCombo and an Image property
that can define the graphic to show on a
FIGURE 2.6 All the new Windows line within the ImageCombo. As with
common controls are embedded in the most of the new graphical ActiveX
OCXs MSCOMCTRL.OCX, controls, the ImageCombo has an
MSCOMCT2.OCX, and ImageList from which it references
COMCT332.OCX. images and pictures.

20 Modul Pembuatan WEB


Use the code in Listing 2.2 to add a The FlatScrollBar Control
ComboItem that has a graphic to an
ImageCombo. This code is from the Visual Basic 6 provides a new variation of
cmdAddCbo_Click() event procedure of the familiar scrollbar control: the
the CommandButton cmdAddCbo, FlatScrollBar. The FlatScrollBar is
which is part of the code from the project fundamentally the same as the ScrollBar,
WhatsNew.vbp. You can download the except that the FlatScrollBar has three
code from the Web side dedicated to this Appearance styles: a standard style, a
book. three-dimensional (beveled) style, and a
two-dimensional style that becomes
LISTING 2.2 02LIST02.TXT-- beveled when the mouse pointer hovers
Creating ComboItems and over it (refer to Figure 2.6).
Adding Them to an
ImageCombo Working with the New Language
01 Static i% `A counting integer Features
02 Static imgi% `A index for a
graphic In addition to enhanced and new ActiveX
03 `within an ImageList controls, VB6 also provides new features
04 Dim ci As ComboItem `Object
variable for a within the Visual Basic language itself.
05 `ComboItem Again, if you have no previous experience
06 with Visual Basic, the following sections
07 `Get a reference to ComboItem might seem a bit baffling. You still might
object using
want to read through it anyway, however;
08 `a ComboItems Add method.
09 Set ci = these new features will make your
ImageCombo1.ComboItems.Add programming efforts easier regardless of
10 `Assign some data a line of degree of prior experience.
text
11 `ci.Text = "My Caption " &
CStr(i%) File System Objects
12 `Add a graphic by referencing
an index in the In older versions of Visual Basic, if you
13 `associated ImageList wanted to get file system information or
14 ci.Image = imgi% + 1
15 `Make sure that you haven't
perform file system tasks, such as writing
exceeded the number to a file or changing a directory, you had a
16 `of images in the ImageList number of techniques available, most of
17 If imgi% = which were quite laborious. In Visual
ImageList1.ListImages.Count - 1 Basic 6, all these chores have been
Then
18 imgi% = 0 contained with a new object,
19 Else FileSystemObject, which is part of the
20 imgi% = imgi% + 1 Visual Basic Scripting Library. Thus,
21 End If when you learn to use this object within
22 `Increment the string counter
VB6, you can easily transfer your
23 i% = i% + 1
knowledge to scripting within Internet
Code for the ComboItem Explorer or Internet Information Server to
do system-level programming.
If you're beginning programmer, the code
shown in Listing 2.2 is probably a little
Internet Information Server
beyond your needs right now. This code is
provided to show those with some VB
Internet Information Server (IIS) is a
background how to work with the newer
complex program, the function of which
features of the ComboItem object.
is to deliver information and files over the
Internet. An Internet server is a physical
computer, and IIS is software that runs on
Figure 2.6 shows you the result of an Internet server. As you read in this
clicking the cmdAddCbo button. Notice book, you'll learn that you can use Visual
that the ImageCombo contains a graphic Basic to write programs that are
and a string. extensions of IIS, called IIS Applications.
An application that runs on an Internet
server is called a server-side application.

21 Modul Pembuatan WEB


The FileSystemObject is quite complex. FIGURE 2.7 The project prjFileSystem
It's made of a number of objects and gives you an introduction about how to
methods that encapsulate the file system use the FileSystemObject.
functions, which you use to work with
drives and files on a local machine or over New String Functions
the network. Table 2.1 describes the new
FileSystemObject objects. Visual Basic 6 provides a number of new
functions for working with strings (see
Microsoft Scripting RunTime Table 2.2).
component
TABLE 2.2 The New String
If you plan to program with the Functions
FileSystemObject, make sure that you
include a reference in your project to the Function Name
Microsoft Scripting RunTime ActiveX (Return Type) Description
component. You include a reference to the Filter Allows you to filter a
MS Scripting RunTime through the string for various
References dialog (choose References
from the Project menu). Then select the (string array) substrings
Microsoft Scripting RunTime in the FormatCurrency Allows you to format a
References list. (string) string to currency
FormatDateTime Allows you to format a
(string) string to a time or date
TABLE 2.1 FileSystemObject FormatPercent Allows you to format a
Objects (string) string as a percent
InStrRev (string) Returns the position of
Object Description one string within
Drive Provides properties and another string; unlike
methods for describing InStr, InStrRev starts at
and working with local the end of the string
and network drives being searched
File Provides properties and Join (string) Takes a string array
methods for working and combines its
with files elements into one
string
Folder Provides properties and
methods for working MonthName Returns the name of a
with folders (string) month when you have
the number of the
FileSystemObject Provides properties and
month (for example, 1
methods for defining
returns January)
and working with
collections of drives, Replace (string) Replaces substrings
folders, and files within a string
TextStream Provides properties and Round (string) Returns a rounded
methods that allow you number as specified
work with text files Split (string array) Splits a string into an
array of strings
If you want an introduction to the StrReverse (string) Reverses the order of a
FileSystemObject, the project string--for example,
prjFileSystem.vbp is a small program that "cat" becomes "tac"
shows you how to use the various WeekdayByName Returns the day of the
FileSystemObject features to find out how (string) week
many drives are on your computer (see
Figure 2.7). Also, when you select a found
drive, the program reports back the As you can see in Table 2.2, some new
amount of unused disk space on a drive. string functions return string arrays. The
You can find the project capability of a function to return an array
prjFileSystem.vbp on the Web site is also a new feature in VB6.
dedicated to this book.

22 Modul Pembuatan WEB


Each new function listed in Table 2.2 18 Sub cmdButton _Click()
19 cmdButton.Caption = "At last,
could warrant a section of a chapter
real OOP!
dedicated solely to it. Clearly, such 20 End Sub
description is beyond the scope of this
chapter, but if you need more details for If you want to see this code in action, go
how to use a specific string function, read to the project prjDynCtrl.vbp on the Web
the documentation that comes with your site dedicated to this book.
edition of VB6 or Chapter 12, "Working
with Strings and Typecasting."
Learning About VB and the
True Dynamic Control Creation Internet
Working with DHTML
On-the-fly versus runtime
Dynamic Hypertext Markup Language is
The phrase on-the-fly is used when you
an extension of HTML (Hypertext
are creating something while a program is
Markup Language), the language of the
running. Another term for the state when a
Internet. All Web browsers, regardless of
program is running is runtime.
manufacturer, use HMTL to decode
information passed through the Internet
that's presented to end users. DHTML
For those of you familiar with VB, you takes HTML one step further by
might know that in prior versions of VB permitting a greater degree of
you created controls on-the-fly by using programmability to take place. Thus, with
control arrays. One drawback to creating DHTML you can send code via the
controls with a control array was that at Internet that allows end users to move
least one control had to be present on a things around the computer monitor with
form for you to create others dynamically. a mouse, to hide things, or even to delete
This is no longer true in VB6; you can items.
create a control at runtime purely from
code by using the Add method of the
Controls collection.
Visual Basic has been positioned very
nicely for Internet development. You can
Listing 2.3 shows you the code that you
use VBScript to write applications that run
must use to create a CommandButton
on your desktop computer with Internet
purely from code, without having to drag
Explorer. Also, you can use VBScript on
a CommandButton from the ToolBox
the server side to work with Internet
first.
Explorer. Visual Basic 6 has sharpened the
focus on Internet development; it extends
LISTING 2.3 02LIST03.TXT-- your ability to write server-side
The New Add Method for the applications for Microsoft's Internet
Controls Collection Information Server by introducing a
01 Option Explicit project type named IIS Applications. Also,
02 `WithEvents is a way tell the Visual Basic extends and simplifies
program to
DHTML (Dynamic Hypertext Markup
03 `respect all the events that
are associated Language, the language used by all Web
04 `a CommandButton such as the browsers) by introducing a project type
click event. named DHTML Applications. For more
05 Private WithEvents cmdMyButton about programming with VB, VBScript,
As CommandButton
06
and DHTML, read Chapter 28, "Creating
07 Private Sub Form_Load() VB Programs for the Internet."
08 Set cmdButton =
Controls.Add("VB.CommandButton", _ An IIS application is a Visual Basic
"Button") program that resides server side as an
09 With mdButton
10 .Visible = True extension of Internet Application Server.
11 .Width = 3000 An IIS application is called by a client
12 .Caption = "A real surprise" computer via the Internet. Although the
12 .Top = 1000 Visual Basic IIS Application sends data
14 .Left = 1000
15 End With
back to the calling client through HTML,
16 End Sub the actual calculation on the server-side
17 computer is done by using compiled

23 Modul Pembuatan WEB


Visual Basic code. This enhancement is Chapter 20, "Deploying Your Visual Basic
significant; before this, IIS Applications Applications."
were written in C++ or, if you wanted to
program IIS, you had to do it with Finding Out About the New Data
VBScript under Active Server Pages Capabilities
(ASP).
Visual Basic 6 supports ActiveX Data
VB's integrated development Objects (ADO). In prior versions of VB,
environment data access was handled under the
umbrella of Data Access Objects (DAO)
IDE stands for integrated development and Remote Data Objects (RDO). ADO
environment. The Visual Basic IDE is has combined and superseded these
your programming workbench, where you technologies. ADO is easier to use and has
write and debug code as well as manage a broader scope of implementation. You
your applications. You'll learn more about can use ADO to connect to a database on
the Visual Basic IDE in Chapter 3, a local desktop or to a remote database
"Working in the Visual Basic 6 server. Also, ADO allows you to access
Programming Environment." more types of data--e-mail, for example.

The current ADO technology is contained


A DHTML application is a project that within the new ADO Data control. The
presents a Visual Basic Designer, a tool ADO Data control might look the same as
that automates the writing of VB code. the familiar Data control of prior versions,
The DHTML Application Designer allows but when you look at the Property Page of
you to write DHTML code within the the control (see Figure 2.8), you see a
Visual Basic IDE. You can find the actual significant difference. The ADO control
DHTML on the IIS Web server in the allows you to connect to a desktop
form of an ActiveX DLL. This is database file or an ODBC server on a
significant because DHTML is somewhat network, or you can create a new
different than VB code. Thus, you're connection to another database.
leveraging the inner workings of IIS and
VB to actually translate VB into DHTML FIGURE 2.8 The ADO data control
at runtime. combines the functionality of DAO and
RDO, as well as allows you to access
One problem with programming for the non-traditional data types such as e-mail
Internet is that the programming dynamic or files within the file system.
is stateless by nature. Interaction is
analogous to a telephone call. Every time In addition to ADO, Visual Basic 6 also
you contact a server on the Internet, it's as comes with a new set of tools and
though you're making a telephone call to a technologies that make data access easier.
stranger who has no prior knowledge of The Data Environment Designer allows
the information passed in any previous you to view and manipulate data in
call. Therefore, working with a body of various databases. Because data
data that must be transmitted from session environments are objects in their own
to session is difficult. Visual Basic uses a right, you can use them as you would a
new feature within Internet Explorer, the Data control. You can even bind other
Global Property Bag, to allow you to controls, such as a TextBox or Label, to a
share information from session to session. Data control.

Microsoft has extended the Setup Wizard Some new data controls allow you take
into a set of new tools to make publishing advantage of the enhancements built into
your application to and deploying it from the ADO Data control. The DataGrid
a Web server easier. These tools--the Web allows you to view your data in a row and
Publishing Wizard and the Package and column format. The DataList and
Deployment Wizard--come as part of your DataCombo are similar to the DBList and
purchase when you buy your edition of DBCombo in earlier editions of VB; you
Visual Basic 6. You'll take a close look at can use them to get a pick list of data from
the Web Publishing Wizard and the an ADO control in a ListBox or
Package and Deployment Wizard in ComboBox configuration. You also can
use the more advanced FlexGrid and

24 Modul Pembuatan WEB


hierarchical FlexGrid controls to get a IDE. The Application Wizard is an add-in,
clear, visual view of complex data. Visual as is the Data Forms Wizard.
Basic also provides a new Data Setup
Wizard to make deploying your larger-
scale database applications easier. Probably the most helpful additions to
Visual Basic 6 are all the new wizards that
Visual Basic 6 enhances its reporting come bundled with it. Table 2.3 briefly
capabilities with the Data Report Designer describes each new wizard and add-in.
(see Figure 2.9), which lets you create,
preview, and print reports in Visual Basic TABLE 2.3 Visual Basic 6
as you would in Access. (If you've worked
Wizards and Add-Ins
in Access 97, you'll find the Data Report
Designer familiar.) You set report controls Wizard/Add-In Description
from the new Data Reports Toolbox (VB All Editions
also has some new IDE features) onto the
Package and Helps you prepare and
Data Report form. Then you invoke the
Deployment deploy your
Data Report's PrintReport() method.
Granted, as you go along, you'll find Wizard application for desktop or
things to be more complex. You can get network use.
more details on Data Environments and Application Helps you set up a
Data Reports in the chapters in Part V of Wizard framework for your
this book, "Database Programming with application. It
Visual Basic 6." automatically adds menus,
toolbars, resource files,
FIGURE 2.9 The Data Report Designer intrinsic ActiveX controls,
brings the ease of Access 97 reporting to and data controls.
Visual Basic. Wizard Helps you organize the
Manager various wizards that you
New Object Programming can access within your
Additions IDE.
Professional
Visual Basic 6 has made creating classes and Enterprise
and ActiveX controls a much broader Editions
activity. You can now save your custom-
made class's data from session to session Data Object Helps you create data
in a Property Bag. You can also create two Wizard objects bound to data
new types of data-aware custom classes, controls and custom
Data Sources and Data Consumers. These ActiveX controls.
types of data classes behave very much as Class Builder Helps you visually build
the ADO Data objects, except they allow Utility custom classes.
you to have more flexibility to suit your ToolBar Wizard Helps you visually create
custom needs. custom toolbars for your
forms.
With regard to custom ActiveX controls,
Data Form Helps you create forms
you now can make lightweight ActiveX
Wizard with controls that reference
controls in VB6. These types of controls
data in a database.
are "windowless" and thus require fewer
system resources than full-fledged Add-In Helps you create custom
ActiveX controls. To determine if an Designer VB add-ins.
ActiveX control is indeed windowless, Property Page Helps you create property
Visual Basic provides a new property, Wizard dialogs for the ActiveX
HasDC. controls you make in VB.
T-SQL Helps you debug code that
Using add-ins Debugger you write for Microsoft's
SQL Server Database.
An add-in is a Visual Basic tool that VB
API Viewer Helps you work with
programmers make for other VB
declares (functions),
programmers. An add-in is written in VB
constants, and types from
and can run only within the Visual Basic
the Windows API.

25 Modul Pembuatan WEB


ActiveX Helps you make ActiveX
Control controls.
Interface
Wizard

26 Modul Pembuatan WEB