visual basic coding

27
Visual Basic Code Angelika Cabus Juanito Bibat

Upload: sara-corpuz

Post on 05-Dec-2014

765 views

Category:

Technology


10 download

DESCRIPTION

 

TRANSCRIPT

Page 1: Visual basic coding

Visual Basic Code

Angelika CabusJuanito Bibat

Page 2: Visual basic coding

Code for Visual Basic

There are many sources of code within the Visual Basic documentation set. This topic helps you get started in locating that code. Note that some of this code is contained within topics that provide further explanation or instructions on how to perform a task, whereas some is contained in special topics devoted only to displaying a code example.

Page 3: Visual basic coding

Visual Basic applications usually consist of the following:

1.Forms-an application may consits of one or more forms.

2.Form controls-forms are created with controls.

3.Code-programming language that will direct application execution.

Page 4: Visual basic coding

*Form module-a module file that holds one or more forms.

*Standard module-a file that holds code that is not related to a form.

*String-a series of characters that is treated as a single entity.

* Input and output-are terms used to describe the method of receiving data and sending data from the computer to the user.

Page 5: Visual basic coding

Output / Input

Page 6: Visual basic coding

FORM

Page 7: Visual basic coding

STANDARD MODULE

FORM MODULE

Page 8: Visual basic coding

STRING

Page 9: Visual basic coding

Data basics:)

Page 10: Visual basic coding

Data typesThe three broad categories of data in Visual Basic.

1.numeric-for numbers used in data 2.string-for alphanumeric data3.special-for special data type including items that check box values

Page 11: Visual basic coding

Description and range

Data type that takes one of two of the following values true or false.

Numeric values without decimals from 0 to 255

VISUAL BASIC DATA TYPES

BOOLEAN

BYTE

Page 12: Visual basic coding

Here's a simple Visual Basic form. It looks just like any other form that you use in Windows applications. The header area has a caption, the control menu, and the minimize/maximize/close buttons. The the large area of the form is called the client area.

DATEHolds tdate and time values from 0:00:00(midnight) on january 1, 0001 through 11:59:59 PM on december31, 9999

DecimalThat represents numbers with 28 decimal places

DoubleNumeric values from -1.79769313486232E+308To 1.79769313486232E+308.

Page 13: Visual basic coding

INTEGERNUMERIC VALUES WITH NO DECIMAL POINT FROM -32,768 TO 32,767

LONGTHE INTEGER DATA VALUES FROM-2,147,483,647

OBJECTSPECIAL DATA TYPE THT HOLDS CONTROLS AND FORMS.

SINGLE NUMERIC VALUES FROM -3.402823E+38 TO 3.402823E+38.

Page 14: Visual basic coding

THE DIM STATEMENTS LOCATION Dim that appears in an event procedure and can only be used within that event procedure called a Local variable.Dim in a module’s general section that can access all the variables within that module is called Global variable.

Page 15: Visual basic coding

The Dim statement is usually written in the following format:*Dim VarName As DataType*VarName is a variable name that you create.

Page 16: Visual basic coding

Prefix Data type

exampleBln Boolean blnlsOverTime

Byt Byte bytAge

Cur CurrencycurHourlyPay

Dtm

Date

dblMicroMeasurement

Dbl Double

dteFirstBegan

Page 17: Visual basic coding

Lng

Long lngStarDistanceOb

jObject

objSoundClipSng Singl

esngYearSalesStr Strin

gstrLastNameVnt

or var

VariantvntControlValue

ingCount

Integer

Int

Page 18: Visual basic coding

Take note of the following code:

curNetSales =curGrissSales - curCostOfSales

intResult = (1 + 2 ) * 3

Page 19: Visual basic coding

Working with scientific notation

Scientific notation is used to represent extremely large and small decimal numbers without including a lot of zeros or other digits.

Page 20: Visual basic coding

To convert a scientific notation value to its real value:

1.After the D or E ,raise 10 to the number.for example,the +6 in the number 1.2345E+6 raise 10 to the 6th power to get 1,000,000.

2.Multiply the number at the left of the D or E by the value in step 1.Multiply 1.2345 by the 1,000,000 to get a result of 1,234,500.

Page 21: Visual basic coding

Variables that hold data

To hold data that can change based on calculations or the changes can be stated within the application,variables must be declared.The Dim statement lets you recognize that the variables holds the Currency data type andThe curToTalSales is the variable’s name.

Page 22: Visual basic coding

Expressions and math operators Math operators allow calculation and assignment of expression results to variables when you code assignment statements that contain expressions.

Page 23: Visual basic coding

Visual basic primary math operatorsOperator Description

+-

Adds two values

Subtracts one value from another value

Page 24: Visual basic coding

* Multiplies two values

/ Divides one value by another value

^ Raises a value to a power

& (or +)Concatenates two strings

Page 25: Visual basic coding

Concatenation The concatenation operator joins one string to the end of another.

Page 26: Visual basic coding

Take note of the following code:

strFullName = lblFirstName & “ “ & lblLastName

Page 27: Visual basic coding