Sie sind auf Seite 1von 18

Second Quarter

ICT Reviewer
Reviewer in ICT
Second Quarter

LESSON #1: CASE STATEMENT:


A Select Case statement allows a variable to be tested for equality against a list of values.
Each value is called a case, and the variable being switched on is checked for each select case.

When a multiple-alternative selection structure has many paths from which


to choose, it is often simpler and clearer to code the selection structure using
the Select Case statement rather than several If ThenElse statements.

The syntax for a select case statement is as follow:


Select Case expression
CASE [expressionlist]
[statements]
CASE ELSE
[elsestatements]
End Select
Example:

Whereas:
Expression - an expression that must evaluate to any of the elementary data type in
VB.Net, i.e., Boolean, Byte, Char, Date, Double, Decimal, Integer.
Expressionlist - list of expression clauses representing match values for expression.
Multiple expression clauses are separated by commas.
o Example of valid expression lists:
CASE 1 TO 5
CASE IS > 90
CASE 2, 4, 8

Credits to: Jovito San Luis III jvsanluis3@gmail.com


Second Quarter
ICT Reviewer
Statements - statements following Case that run if the select expression matches any
clause in expressionlist.
Elsestatements - statements following Case Else that run if the select expression does
not match any clause in the expressionlist of any of the Case statements.

What is keypress event?


To allow a text box to accept only certain keys: Code the text boxs KeyPress event
procedure.
The key the user pressed is stored in the e.KeyChar property.
You use the e.Handled = True instruction to cancel the key pressed by the user

Sample Code:
Private Sub TextBox1_KeyPress(ByVal sender As Object, ByVal e As
System.Windows.Forms.KeyPressEventArgs) Handles TextBox1.KeyPress
If (e.KeyChar < "0" Or e.KeyChar > "9")
And e.KeyChar <> "."
And e.KeyChar <> ControlChars.Back Then
' cancel the key
e.Handled = True

End If
End Sub

Credits to: Jovito San Luis III jvsanluis3@gmail.com


Second Quarter
ICT Reviewer
LESSON #2: THE REPETITION STRUCTURE:
The repetition structure:
Referred to more simply as a loop
Loop can be phrased into two ways:
o Looping condition the requirement for repeating the instruction
o Looping exit condition the requirement for not repeating instruction (stop)

DO {WHILE|UNTIL} LOOP
Use the While keyword in a looping condition to specify that the loop body should be
processed while (in other words, as long as) the condition is true.
Use the until keyword in a loop exit condition to specify that the loop body should be
processed until the condition becomes true, at which time the loop should stop.
Like the condition in an IfThenElse statement, the condition in a Do . . . Loop
statement can contain variables, constants, properties, methods, keywords, and
operators; it also must evaluate to a Boolean value.

In a pre-test loop
The condition is evaluated before the instructions within the loop are processed.
Syntax:

Do {While | Until} condition


loop body instructions, which will be processed either while the condition is true o
until the condition becomes true

Loop

Example code:
Dim intNumber As Integer = 1

Do While intNumber <= 3


MessageBox.Show(intNumber)
intNumber = intNumber + 1
Loop

In a post-test loop
The condition is evaluated after the instructions within the loop are processed.
Syntax:

Do
loop body instructions, which will be processed either
while the condition is true or until the condition becomes true
Loop {While | Until} condition

Credits to: Jovito San Luis III jvsanluis3@gmail.com


Second Quarter
ICT Reviewer
Example Code:
Dim intNumber As Integer = 1

Do
MessageBox.Show(intNumber)
intNumber = intNumber + 1
Loop Until intNumber > 3

Counter and Accumulators:


A counter is a numeric variable used for counting something, such as the number of
employees paid in a week.
A counter can be updated by incrementing (or decrementing) its value by a constant
amount, which can be either positive or negative, integer or non-integer.
An accumulator is a numeric variable used for accumulating (adding together)
something
An accumulator can be done by incrementing (or decrementing) its value by an amount
that varies. The amount can be either positive or negative, integer or non-integer.
The initialization of both counter and accumulator is done outside of the loop that uses
the counter; the update is done within the loop.
Initializingthe process of assigning a beginning value to a memory location, such as a
counter or an accumulator variable

Credits to: Jovito San Luis III jvsanluis3@gmail.com


Second Quarter
ICT Reviewer
NOTES:
The condition appears at the beginning of a pretest loop, but at the end of a posttest
loop. For that reason, pretest and posttest loops are also called top-driven and bottom
driven loops, respectively.
You can nest loops, which means you can place one loop within another loop.
You can use the Exit Do statement to exit the Do . . . Loop statement prematurely, which
means to exit it before the loop has finished processing. You may need to do this if the
computer encounters an error when processing the loop instructions.

Credits to: Jovito San Luis III jvsanluis3@gmail.com


Second Quarter
ICT Reviewer
LESSON #3: FOR NEXT STATEMENT:
What are For Loop Statements?
For...next loops are used to repeat a section of code a number of times with a control
variable, which has a differing value each time through the loop.
The 'start' and 'end' values specify what the control variable's values will be and how
many times the loop is executed.

Remember these terms:


Variable - will be used as the loop counter
Start - is the initial value of variable
End - is the finish value of variable
Increment - is an optional value which overrides the default counter value of +1. If
Increment is preceded by a '-', it will be assumed that Start is greater than End, and
therefore increment will be subtracted (rather than added) on each loop.

Codes:

FOR variable = start TO end


{code}
NEXT {variable}
FOR variable = start TO end STEP {-}increment
{code}
NEXT {variable}
FOR variable = start DOWNTO end
{code}
NEXT {variable}
FOR variable = start DOWNTO end STEP decrement
{code}
NEXT {variable}

Credits to: Jovito San Luis III jvsanluis3@gmail.com


Second Quarter
ICT Reviewer
LESSON #4: TIMER CONTROL:
What is the Timer Function?
Timer Control plays an important role in the Client side programming and Server side
programming, also used in Windows Services.
By using this Timer Control, windows allow you to control when actions take place
without the interaction of another thread.

Use of Timer Function:


We can use Timer Control in many situations in our development environment. If you
want to run some code after a certain interval of time continuously, you can use the
Timer control.
As well as to start a process at a fixed time schedule, to increase or decrease the speed
in an animation graphics with time schedule etc. you can use the Timer Control.
The Visual Studio toolbox has a Timer Control that allowing you to drag and drop the
timer controls directly onto a Windows Forms designer. At runtime it does not have a
visual representation and works as a component in the background.

How to Use the Timer Function:


With the Timer Control, we can control programs in millisecond, seconds, and minutes
and even in hours. The Timer Control allows us to set Interval property in milliseconds (1
second is equal to 1000 milliseconds).
For example, if we want to set an interval of two minute we set the value at Interval
property as 120000, means 120 x 1000.
The Timer Control starts its functioning only after its Enabled property is set to True, by
default Enabled property is False.

Credits to: Jovito San Luis III jvsanluis3@gmail.com


Second Quarter
ICT Reviewer
LESSON #5: INTRODUCTION OF MICROSOFT ACCESS DATABASE 2010
Introduction:
Microsoft Access is a database management system (DBMS) from Microsoft that
combines the relational Microsoft Jet Database Engine with a graphical user interface
and software-development tools
A member of the Microsoft Office suite of applications, included in the Professional and
higher editions or sold separately.
Microsoft Access stores data in its own format based on the Access Jet Database Engine
It can also import or link directly to data stored in other applications and databases.
Used for developing a software.
Access is supported by Visual Basic for Applications (VBA), an object-based
programming language that can reference a variety of objects.

Timeline:
1992: Microsoft released Access version 1.0 on November 13, 1992, and an Access 1.1 release in
May 1993 to improve compatibility with other Microsoft products and to include the Access Basic
programming language.

1994: Microsoft specified the minimum hardware requirements for Access v2.0 as: Microsoft
Windows v3.1 with 4 MB of RAM required, 6 MB RAM recommended; 8 MB of available hard disk
space required, 14 MB hard disk space recommended. The product shipped on seven 1.44 MB
diskettes. The manual shows a 1994 copyright date.

With Office 95, Microsoft Access 7.0 (a.k.a. "Access 95") became part of the Microsoft Office
Professional Suite, joining Microsoft Excel, Word, and PowerPoint and transitioning from Access
Basic to VBA. Since then, Microsoft has released new versions of Microsoft Access with each
release of Microsoft Office. This includes Access 97 (version 8.0), Access 2000 (version 9.0),
Access 2002 (version 10.0), Access 2003 (version 11.5), Access 2007 (version 12.0), Access 2010
(version 14.0), and Access 2013 (version 15.0).

Opening Microsoft Access:


1. Open a database from within Access
If Access is already running, use the following procedure to open a database:
1. Click the Microsoft Office Button, and then click Open.
2. Click a shortcut in the Open dialog box, or in the Look in box, click the drive or
folder that contains the database that you want.
3. In the folder list, browse to the folder that contains the database.
4. When you find the database, do one of the following:
a. Double-click the database to open it in the default mode specified in
the Access Options dialog box or the mode that was set by an administrative
policy.

Credits to: Jovito San Luis III jvsanluis3@gmail.com


Second Quarter
ICT Reviewer
b. Click Open to open the database for shared access in a multi-user
environment so that you and other users can read and write to the database.
c. Click the arrow next to the Open button and then click Open Read-Only to
open the database for read-only access so that you can view but not edit it.
Other users can still read and write to the database.
d. Click the arrow next to the Open button and then click Open Exclusive to
open the database with exclusive access. When you have a database open
with exclusive access, anyone else who tries to open the database receives a
"file already in use" message.
e. Click the arrow next to the Open button and then click Open Exclusive Read-
Only to open the database for read-only access. Other users can still open the
database, but they are limited to read-only mode.

Open multiple databases at the same time:


In a single instance of Access, you can have only one database open at a time. In other
words, you cannot start Access, open one database, and then open another database
without closing the first database. However, you can run multiple instances of Access at
the same time, each with a database open in it. Each time you start Access, you open a
new instance of it. For example, to have two Access databases open at the same time,
start Access and open the first Access database, and then start a new instance of Access
and open the second database.
NOTE: The number of instances of Access that you can run at the same time is limited by
how much memory is available. Available memory depends on how much RAM your
computer has and how much memory is being used by the other programs running at the
time.
o Each instance of Access runs in a separate window. If you have more than one
instance of Access running and you want to view them simultaneously, you can
tile the windows.

To tile more than one Access window:


1. For each program that you do not want to tile, click the Minimize button in the upper-
right corner of the window.
2. Right-click the Windows taskbar, and then click Tile Windows Vertically.
3. After you have tiled the windows, you can more easily copy and paste data or drag and
drop database objects between the Access databases.

Create a desktop shortcut to open a database object:


1. Open the database containing the object for which you want to create a shortcut.
2. Resize the Access window and minimize any other open windows so that you can see
the desktop behind the Access window.
3. In the Navigation Pane, find the object for which you want to create the shortcut.
4. Drag the object from the Navigation Pane to the desktop. When you release the
mouse button, the shortcut is created on the desktop.

Credits to: Jovito San Luis III jvsanluis3@gmail.com


Second Quarter
ICT Reviewer
5. If you want the shortcut in a location other than the desktop, use Windows Explorer
to move the shortcut to the location you want.

When you double-click the shortcut, Access opens the database in which the object is
stored and displays the object. If Access is already running and the object associated with the
shortcut is in a database other than the currently open database, a new instance of Access is
started. To open the object in a specific view in Access, right-click the shortcut and then click the
view you want.

NOTE:
If you move the database after you create the shortcut, delete the shortcut and create a
new one.
To delete a shortcut, click it and then press the DELETE key. Deleting the shortcut does
not delete the object that the shortcut opens.

Uses of Microsoft Access:


Business
o If you start a business, you certainly often work with database. For example, you
want to make the data of financial report of your business. It will be much easier
and better with Microsoft Access. So, you have to buy the software, learn it, and
practice using it. Therefore, I can say that it is considered as one of the 5 uses of
Microsoft Access.
Schools
o If you are a student of administration or statistics, you certainly often use
database. The schedules include for all the teachers and for the students each
class which means schedules of lessons. It is also very useful for those who work
in the library at your school to ease you to use database, Microsoft Access will be
very helpful. It can ease you to create, edit, and maintain database.
Office
o For office, there are many positions of people who often work with database. For
examples are secretary, HRD, and financial planner. However, some other
positions may also work database.
For Workplace
o If you have ever created or joined an organization, of course you know about the
activities to do in the workplace. In this case, what I mean is related to the report
need. For examples are income and outcome report, activity plan, and there are
still many things to report. Those reports will be much easier to create with
Microsoft Access.
For Programmers
o Programmers also often work with database. Microsoft Access is very useful for
programmers to ease their activities related to programming. That is why if you
are a programmer, you have to know how to use Microsoft Access program.

Credits to: Jovito San Luis III jvsanluis3@gmail.com


Second Quarter
ICT Reviewer
Advantages of Microsoft Access:
Has built in report generator (found only on VS Professional Edition)
Easy to deploy. It does not required .NET framework (In .Net you need to be careful how
you do this)
Has many solutions already built for it
Easy to code it to do emails and printing of labels (not as easy with .NET)
Does a good job for simple applications where the user can manage data directly even
without coding
Provides OLAP reporting out-of-the-box

Disadvantages of Microsoft Access:


Costs money
MS-Access security is not all that powerful (as I hear - Not sure aobut that).
Ms-Access forces you to work with VBA - Not a full OO language
Has basic Data Grid control as well as other simple controls only. It is not possible to build
advanced custom controls.
Code and data exist together in one file
May not be easy to provide code sharing amongst developers
Not a good choice for web sites of many users
Does not provide full text search (as in SQL Server for example)
.COM based

Credits to: Jovito San Luis III jvsanluis3@gmail.com


Second Quarter
ICT Reviewer
LESSON #6: CONNECTING DATABASE TO VISUAL BASIC 2010
Basic terms to remember:
Database an object for strong collection of structured data
Database Management System (DBMS) programs with software system
designed to use standard methods in listing, recording, and gathering
queries on data to maintain the database.
ADO.NET a new database technology of the .NET platform that provides access
to database of different data providers.
DataSet stands as an equivalent data disconnected from its original data source.
It represents the result of commands used in the project.
Data Source Configuration Wizard a tool used to create or edit database
connection from your application or program.
Structured Query Language (SQL) a special language used to access, store, and
update data in a database.
Binding Navigator a class used for navigation on a form represented by an
interface for connected data.
Relationship are connection links between tables.

What is database?
A database is an object for storing collection of structured data.
Although a database is a storage location, the main purpose of a database is not much of
a storage but rather focused on quick retrieval and manipulation of information.
To isolate complexities with regards to the internal representation of the database,
database management system (DBMS) programs are commonly used.
Some of DBMS examples include MySQL, Microsoft Access, Oracle and FoxPro.
Their software system are designed to use standard methods in listing, recording, and
generating queries on data to maintain database.
Their capabilities enables programmers to access and store data in an organized manner,
in form of tables.

Connecting an Microsoft Access Database to Your Project


1. Create a new Windows Form application with the name LibrarySystem.
2. Create an interface as shown below.

Credits to: Jovito San Luis III jvsanluis3@gmail.com


Second Quarter
ICT Reviewer
3. Create a new blank Microsoft Access database and save it in your folder as
UserAccounts.accdb.
4. Create a table with the following fields and data.

5. Save the file and close.


6. In your Visual studio project, Click on Projects menu then choose Add New Data
Source to launch the Data Source Configuration Wizard.
7. For the Data Source Type, select Database then click Next.
8. Select Dataset as your Database Model, then click Next.
9. On Data Connection page, click on New Connection.
10. In the Choose Data Source dialog box, select Microsoft Access Database File as your
data source then click Continue.

As shown in the description, Microsoft Access Database file uses .NET Framework
Data Provider for OLE DB.

11. For Database file name, search for UserAccounts.accdb file that was created earlier.
12. To verify connection to your database, click Test Connection.
13. Once the connection was verified, click ok twice to close the Test Connection and Add
Connection dialog box.
14. Click Next on the Data Source Connection Wizard.
15. If a prompt asks you to copy the file to your project, click Yes
16. Save the Connection as UserAccountsConnectionString, then click Next.
17. Add all your objects in the dataset, then click Finish.
18. On your Solution Explorer, open UserAccountsDataSet.xsd in designer mode (Shift +
F7).

The Structured Query Language


To access stored data in the database and to update a database, a special language,
Structured Query Language is used.
SQL is a universal language for manipulating tables and was supported in any DBMS.
Although it requires familiarity with its syntax, and is a nonprocedural language, some
tools are available in order to generate SQL statements with point-and-click operations.
SQL keywords:

Credits to: Jovito San Luis III jvsanluis3@gmail.com


Second Quarter
ICT Reviewer

Creating SQL Database Query:


1. Make sure that UserAccountsDataSet.xsd is opened in designer mode.
2. Right click on AccountsTableAdapter, then click on Add, then Query.
3. On the TableAdapter Query Configuration Wizard, select Use SQL statements then
click Next.
4. For the query type, select SELECT which returns a single value
5. Click on the Query Builder button to specify SQL Select statement.
6. On the query builder, in the first row, replace the Alias Expr1 to Result, then Filter
to =1.
7. In the second row, select Username as Column, then enter UsernameInput as
Alias then =? as Filter.
8. In the third row, select [Password] as Column, then enter PasswordInput as Alias,
then =? as Filter.
9. To test the generated SQL code, click on Execute Query from the lower left of the
builder.
10. On the Query Parameters, under Value, enter a username and password as indicated
on the created Microsoft Access database, then click OK.
11. Click OK to close the builder, then, click Finish to close the Wizard.
12. On the UserAccountDataseSet, right-click on ScalarQuery(Username,Password), then
choose Configure.
13. Click Next on the wizard to proceed.
14. Name the new function as UsernamePasswordString.
15. Click On Finish.

Associate a Query into Object in a Project:


1. Open the Log-in Page form in design view
2. In the Toolbox, locate the AccountsTableAdapter located under LibrarySystem
Components.
3. Click and drag the adapter into the form.

Credits to: Jovito San Luis III jvsanluis3@gmail.com


Second Quarter
ICT Reviewer
4. Double click on the Log-in button to view code.
5. Enter the codes below:

6. Run the program.

Additional Information to Database:


In a database, data are stored into tables, which contains data of the same type or
category. When creating a database for a library system, separate tables are created for
book titles, authors, or publishers. Changing information from one table that is related to
other tables will be difficult in this case.
The reason for separating tables in a database may be a puzzle for some, but this step
actually helps in eliminating duplicates within the database.
The process of separating related data into tables with the aim of eliminating possible
duplicates is called normalization.
In order to properly use the tables, the connections between the data from different
tables must be properly identified.
Connections must be established in such a way that all relevant information for a
particular data can be retrieved in a glance.
The connections or links between tables are called relationships, they are at the center
of most modern DMBS.
Being able to interconnect table and information from within them is what make a
database different from a regular worksheet (Excel).

Relational Databases:
Relational databases are the main concern for relational model since they are based on
the relationship between the data they contain. Tables contains group of related data or
entries keeping each tables as manageable as possible.
Separate entities are placed on a different table avoiding information to be manually
entered multiple times making it prone to duplication.
One of the main goals in creating a database is to keep information organized and
manageable.
Along with the goal is a simple rule that is followed by database designers: Do not
duplicate information.

Credits to: Jovito San Luis III jvsanluis3@gmail.com


Second Quarter
ICT Reviewer
Creating Relation between Tables:
1. Create a Microsoft Access database named LibrarySystem.accdb and save in your folder.
2. Create three tables with the following contents:

Table 1: Books

Table 2: Members

Table 3: Members

3. Create a Windows Form project named LibraryDatabase and connect the LibrarySystem
database into the project.

The number 1 and the infinity symbol on the line defines how objects are related to
each other.

4. From the Solutions Explorer open LibrarySystemDatabase.xsd in designer mode.


5. Right-click on the designer, choose Add, then select Relation.

Credits to: Jovito San Luis III jvsanluis3@gmail.com


Second Quarter
ICT Reviewer
6. Set the Relations dialog box, then click OK.
7. Create another relation for the Books and Transactions Table. Click Ok when done.
8. Save and close the database.

Updating Data in a Database


1. Create a windows form project and save the project as LibraryDatabase.
2. On TextBox1 properties, under DataBindings, select Text and choose Add Project Source.
3. Using the wizard, add connections to the LibraryDatabase and selecting only the books
table.
4. Again on TextBox1 properties, under DataBindings, select Text, then choose BookID under
BooksBindingSource
5. On TextBox2 properties, under DataBindings, select Text, then choose Title under
BooksBindingSource.
6. Do the same process for the other TextBoxes choosing the corresponding table column.
7. On Binding Navigator properties, for the BindingSource, choose BooksBindingSource.
8. Save the project and close.

P.S.: Goodluck sa exam mga lodi! Kaya niyo yan


#petmalu

Credits to: Jovito San Luis III jvsanluis3@gmail.com


Second Quarter
ICT Reviewer

Credits to: Jovito San Luis III jvsanluis3@gmail.com

Das könnte Ihnen auch gefallen