Chemical Education Journal (CEJ),
Vol. 10, No. 2 /Registration No. 0-13/Received April 30, 2008..
URL = http://chem.sci.utsunomiya-u.ac.jp/cejrnlE.html
In the ICT age, we use computers for a variety of reasons e.g to surf the internet, write reports, manage database, and solve mathematical problems. Most of the time we will use application softwares to do a given task. There are softwares such as Visual Basic (VB) that can be used to create graphical user interface application programs to solve problems that are of interest to us. This work will demonstrate the use of VB by creating a simple application program known as ChemVB that can be used as a teaching aid in the learning of basic concepts in chemistry. Sample topics included in this application are conversion of units, molecular weight calculator and electrochemistry. This work can be expanded to include other topics in chemistry
As a developing country, Malaysia is experiencing a big change in the society that is geared towards the use of information technology in our daily lives. Computers are used in almost every aspect of activities. Online applications such as internet banking, e-business, e-government and e-education are expanding very rapidly. The government is actively promoting the use of computers and internet by providing the facilities to educational institutions. The use of educational software is started at a very early stage of education process.
In the scientific community, computers are used to do modeling,
simulation, calculate molecular properties or solve complex problems.
If you are a programmer, you can develop your own application
softwares; otherwise we just buy a certain software that suits
our requirement to do or solve a given task. There are many softwares
that are available as freewares or commercially. This website
contains links to many computational chemistry resources: http://www.chem.swin.edu.au/chem_ref.html
ChemOffice and Gaussian are examples of commercial softwares for
drawing chemical structures and for doing computational chemistry.
There are also softwares that we can use to develop our own applications
that suit our needs. One such application is the Microsoft Visual
Basic for Applications or VBA for short. VBA is an object-oriented
programming language that can be used to create graphical user
interface (GUI). A GUI is a graphical (rather than purely textual)
user interface to a computer. Elements of a GUI include such things
as: windows, pull-down menus, buttons, scroll bars, iconic images,
wizards, the mouse probably many things that haven't been invented
yet.
An application known as ChemVB has been developed using VBA.
It is proposed that this application can be used by students of
chemistry from all levels i.e from primary to university level.
The ChemVB has three programs
a) Conversion of units
b) Molecular weight calculator
c) Electrochemistry
The purpose of developing this application is to use VBA as a tool to assist students in learning basic concepts in chemistry. This work will demonstrate how to use ChemVB. Detailed instructions on how to run the application are also given. Other concepts or topics in chemistry can also be developed. The author used (McKeown, 1999) as a reference for VBA programming and specific applications of VBA in chemistry can be found in (Sime, 2005). Incorporating VBA into Excel is described in (Billo, 2001). It is up to one's creativity to explore all the available features of VBA. With routine use and practice, one can design and create an application that is of professional quality.
The ChemVB application was developed using MS Visual Basic 6.0. Basically three steps are involved when a programmer wants to develop an application.
a) Creating the user interface (the form and its embedded controls)
b) Setting the properties of the controls (caption, name, size,
color and other properties)
c) Writing the code (attaching the Visual Basic code to the controls)
Actually the very first step involves planning what the program will do and also how the form (the window that contains the objects) will appear to the user.
Details for creating GUI will not be discussed here but the instructions on how to operate ChemVB are as follows:
Instructions to Open ChemVB
1. Open MS Visual Basic 6.0
2. Click file menu and choose Open project
3. Select ChemVB.vbp
4. A window similar to Figure 1 is displayed. It shows the three
different programs available in ChemVB.
5. Select any of the three programs.
Program 1: Conversion of Units
This program converts the following quantities.
Quantity | From | To |
Temperature | oC | K and F |
Pressure | bar | atm and Pa |
Volume | m3 | cm3 and L |
Energy | J | cal and Latm |
Figure 1. The ChemVB main window
Instructions
1. Select The Conversion Program button.
2. Fill the first column with values of the respective quantities.
All four must quantities must be filled with values. The example
in Figure 2 shows a value of 1 for each quantity.
3. Click the calculate button.
4. The screen will display the converted values in the next two
columns for all four quantities.
5. Click the clear button to repeat using different values.
6. Click exit to go to the main ChemVB window.
Figure 2. The Conversion Program
Program 2: Molecular Weight Calculator
This program demonstrates the calculation of the molecular weight for a given compound that consists up to three elements. This program will also calculate the percentage by mass of each element present in the compound.
Instructions
A. Molecular weight for compounds with 3 elements e.g HNO3
1. Click the Molecular Weight Calculator button in the
ChemVB main window.
2. Click the down arrow of combo box for the first element. Choose
H
3. Click the down arrow of combo box for the second element.
Choose N
4. Click the down arrow of combo box for the third element.
Choose O (Figure 3).
5. In the next column, insert the number of atoms for that element,
1 for H, 1 for N and 3 for O.
6. Click the Calculate MW button. It will display 63.02
as the molar mass for HNO3 and also the
percentage by mass for each element. (Figure
4). The formula for the compound is also displayed.
7. Click the clear button to repeat the calculation for
a different compound.
B. Molecular weight for compounds with two elements (e.g CO2)
1. Choose C for the first element and insert 1
for number of element for C
2. Choose O for the second element and insert 2
for number of element for O
3. Since there are only 2 elements (C and O), for the third element
select X. This is a dummy atom that has mass of 0. So that
its total mass regardless of number of atoms is 0. You must also
insert a number for number of the third element.
4. Click the Calculate MW button. It will display 44.01
as the molar mass for CO2. (Figure
5)
5. Click the clear button to repeat the calculation for
a different compound.
6. You can also view the instruction by clicking the Read Instruction
button.
7. Click the exit button to go to the main ChemVB window
Program 3: Electrochemistry
This program allows the user to choose two half reactions and it will calculate the standard emf for an electrochemical cell formed from these two half-cells. It will determine whether the overall cell reaction is a spontaneous or non-spontaneous.
Instructions
1. Choose the Electrochemistry window in the ChemVB main window.
(Figure 6)
2. Click display data button. The half reactions and the
corresponding standard reduction potentials (on the left column)
and the oxidation potentials will be displayed (in the right column).
3. Choose a reduction half-reaction by clicking on a half-reaction
e.g Cu2+ + 2e
Cu. Click on the next column to select the 0.34 V for
the reduction potential.
4. Click Select R1 button to insert the first half reaction
into the allocated space next to the select R1 button
5. Choose an oxidation half-reaction by clicking on a half-reaction
e.g Zn2+ Zn2+
+ 2e. Click on the next column to select the 0.76 V
for the reduction potential.
6. Click Select R2 button to insert the second half reaction
into the allocated space next to the select R1 buton
7. Click the Calculate the emf cell button. A value of
1.1 V is displayed.
8. To calculate Go, you
must insert a value for n. Type 2 for n
Note: D(delta)Go
= -nFEo , where n
is the number of moles of electrons and F is the Faraday's
constant = 96500 C/mol)
9. Click calculate delta G button. A value of -212.3 kJ
will be displayed. The reaction is a spontaneous reaction. (Figure 7)
10. To select a different half reactions, click the clear
button to clear the entries of all the calculations. The reduction
and oxidation potentials are still in their respective columns
so that you can choose the next pair of half reactions
11. Click the exit button to go back to the main ChemVB
window.
Figure 3. Molecular Weight Calculator window
Figure 4. Results for the molecular weight of HNO3
Figure 5. Results for CO2 (For two elements
in the compound)
Figure 6. A blank Electrochem window before clicking the display
data button
Figure 7. Results for the Zn + Cu2+ Zn2+
+ Cu reaction
Conclusions
Simple concepts involving conversion of units, calculations of molar mass and emf of a cell using VBA have been demonstrated. The programs are quite easy to use and the instructions quite simple and straight forward. These programs have not been tested on the students yet. For future work, the author hopes to apply these programs to two groups of general chemistry students; one group using ChemVB and the other without using ChemVB. These programs can be modified to make it more attractive and other topics can be included to cover other areas of chemistry.
1. WWW Computational Chemistry Resources, http://www.chem.swin.edu.au/chem_ref.html
2. P. G. McKeown, (1999), Learning
to program with Visual Basic, John Wiley and Sons
3. R. J. Sime, (2005), Physical Chemistry
Calculations with Excel, Visual Basic for Applications, Pearson
Education
4. E. J. Billo, (2001), Excel for Chemists
2nd. Ed., John Wiley and Sons