0% found this document useful (0 votes)
27 views

Basic Programming Tutorial

The document provides an introduction to basic programming in Visual Basic, including how to record and edit macros, understanding data types, and creating and designing tables in Microsoft Access. It discusses recording macros in Excel, the Visual Basic interface, common data types like Boolean, Byte, Integer and their purposes, and designing database tables in Access including selecting field names and data types.

Uploaded by

Thabo Chuchu
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
27 views

Basic Programming Tutorial

The document provides an introduction to basic programming in Visual Basic, including how to record and edit macros, understanding data types, and creating and designing tables in Microsoft Access. It discusses recording macros in Excel, the Visual Basic interface, common data types like Boolean, Byte, Integer and their purposes, and designing database tables in Access including selecting field names and data types.

Uploaded by

Thabo Chuchu
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 7

Basic Programming Tutorial

Visual Basic
• Open a Microsoft Excel worksheet
• Click on view, then click on macros, and on the pull
down menu select record macros.
• You can give the recorded macro a name, or use the
default name. This far you have set a macro, so:
• Select the view macro option, and then select edit.
• Now you are in the visual basic interface.
Lets start programming

• Piggery population dynamics:


– User inputs:
• number of sows, non-negative numeric values.
• Number of weeks, prediction time, not more than 30 weeks.
– Validation to ensure the inputs are okey.
• Command 1: Option Explicit
– On Optional. Enables Option Explicit checking. If On or Off
is not specified, the default is On.
– Off Optional. Disables Option Explicit checking.
• Understanding and Optimizing Data Types
– In Visual Basic there are 11 different data types.
– These are Boolean, Byte, Currency, Date, Double, Integer,
Long, Object, Single, String, and Variant.
– They each have a specific purpose and using them
correctly will increase your programs performance.
• Boolean
– The Boolean data type has only two states, True and False.
– These types of variables are stored as 16-bit (2 Byte)
numbers, and are usually used for flags.
• Byte,
• The Byte data type is an 8-bit variable which can store value from 0 to
255. This data type is very useful for storing binary data. It can also be
very useful when sending/receiving byte values to/from a Basic Stamp
or PIC.
• Double
• The Double data type is a 64-bit floating point number used when high
accuracy is needed.
• These variables can range from -1.79769313486232e308 to -
4.94065645841247e-324 for negative values and from
4.94065645841247e-324 to 1.79769313486232e308 for positive
values.
• Integer
The Integer data type is a 16-bit number which can range
from -32768 to 32767.
• Integers should be used when you are working with values
that can not contain fractional numbers.
• Long
– The Long data type is a 32-bit number which can range from -
2,147,483,648 to 2,147,483,647.
– Long variables can only contain non-fractional integer values.
• Single
The Single data type is a 32-bit number ranging from -
3.402823e38 to -1.401298e-45 for negative values and
from 1.401298e-45 to 3.402823e38 for positive values.
• When you need fractional numbers within this range, this is
the data type to use.
• String
– The String data type is usually used as a variable-length type of
variable.
– A variable-length string can contain up to approximately 2 billion
characters. Each character has a value ranging from 0 to 255
based on the ASCII character set.
– Strings are used when Text is involved.
Microsoft Access

• Database creation and management


– Go to All programs, then click on Microsoft
Office, then select Microsoft access. Select blank
database,
– Select Table design, which gives you “field name,
data type and field properties, etc.
– Data type is crucial, Field size is also crucial
• Data sheet
– Lower left corner on the right.

You might also like