Juanito Bibat Angelika Cabus
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.
 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.
* Input and output-are terms used to describe the method of receiving data and sending data from the computer to the user. *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.
Output / Input
FORM
FORM MODULE STANDARD MODULE
STRING
Data basics:)
Data types The three broad categories of data in Visual Basic. 1.numeric-for numbers used in data 2.string-for alphanumeric data 3.special-for special data type including items that check box values
VISUAL Description BASIC DATA and range TYPES Data type that takes one of two BOOLEAN of the following values true or false. Numeric values BYTE without decimals from 0 to 255
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/ma Holds tdate and time values from 0:00:00(midnight) on DATE january 1, 0001 through 11:59:59 PM on december 31, 9999 That represents Decimal numbers with 28 decimal places Numeric values from - Double 1.79769313486232E+308 To 1.79769313486232E+308.
NUMERIC VALUES INTEGER WITH NO DECIMAL POINT FROM -32,768 TO 32,767 THE INTEGER DATA VALUES LONG FROM-2,147,483,647 SPECIAL DATA TYPE OBJECT THT HOLDS CONTROLS AND FORMS. SINGLE NUMERIC VALUES FROM - 3.402823E+38 TO 3.402823E+38.
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.
The Dim statement is usually written in the following format: *Dim VarName As DataType *VarName is a variable name that you create .
Prefix Data type example Bln Boolean blnlsOverTime Byt Byte bytAge Cur Currency curHourlyPay Dtm Date dteFirstBegan Dbl Double dblMicroMeasurement
Int Integer ingCount Lng Long lngStarDistance Obj Object objSoundClip Sng Single sngYearSales Str String strLastName Vnt or var Variant vntControlValue
Take note of the following code: curNetSales =curGrissSales - curCostOfSales intResult = (1 + 2 ) * 3
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.
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.
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 and The curToTalSales is the variable’s name.
Expressions and math operators Math operators allow calculation and assignment of expression results to variables when you code assignment statements that contain expressions.
Visual basic primary math operators Operator Description + Adds two values Subtracts one - value from another value
* Multiplies two values / Divides one value by another value Raises a value ^ to a power Concatenates & (or +) two strings
Concatenation The concatenation operator joins one string to the end of another.
Take note of the following code: strFullName = lblFirstName & “ “ & lblLastName
Visual basic coding

Visual basic coding

  • 1.
  • 2.
    Code for VisualBasic 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.
  • 3.
    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.
  • 4.
    * Input and output-are terms used to describe the method of receiving data and sending data from the computer to the user. *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.
  • 5.
  • 6.
  • 7.
  • 8.
  • 9.
  • 10.
    Data types The threebroad categories of data in Visual Basic. 1.numeric-for numbers used in data 2.string-for alphanumeric data 3.special-for special data type including items that check box values
  • 11.
    VISUAL Description BASIC DATA and range TYPES Data type that takes one of two BOOLEAN of the following values true or false. Numeric values BYTE without decimals from 0 to 255
  • 12.
    Here's a simpleVisual 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/ma Holds tdate and time values from 0:00:00(midnight) on DATE january 1, 0001 through 11:59:59 PM on december 31, 9999 That represents Decimal numbers with 28 decimal places Numeric values from - Double 1.79769313486232E+308 To 1.79769313486232E+308.
  • 13.
    NUMERIC VALUES INTEGER WITH NO DECIMAL POINT FROM -32,768 TO 32,767 THE INTEGER DATA VALUES LONG FROM-2,147,483,647 SPECIAL DATA TYPE OBJECT THT HOLDS CONTROLS AND FORMS. SINGLE NUMERIC VALUES FROM - 3.402823E+38 TO 3.402823E+38.
  • 14.
    THE DIM STATEMENTSLOCATION 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.
  • 15.
    The Dim statementis usually written in the following format: *Dim VarName As DataType *VarName is a variable name that you create .
  • 16.
    Prefix Data typeexample Bln Boolean blnlsOverTime Byt Byte bytAge Cur Currency curHourlyPay Dtm Date dteFirstBegan Dbl Double dblMicroMeasurement
  • 17.
    Int Integer ingCount LngLong lngStarDistance Obj Object objSoundClip Sng Single sngYearSales Str String strLastName Vnt or var Variant vntControlValue
  • 18.
    Take note ofthe following code: curNetSales =curGrissSales - curCostOfSales intResult = (1 + 2 ) * 3
  • 19.
    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.
  • 20.
    To convert ascientific 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.
  • 21.
    Variables that holddata 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 and The curToTalSales is the variable’s name.
  • 22.
    Expressions and math operators Math operators allow calculation and assignment of expression results to variables when you code assignment statements that contain expressions.
  • 23.
    Visual basic primary mathoperators Operator Description + Adds two values Subtracts one - value from another value
  • 24.
    * Multiplies two values / Divides one value by another value Raises a value ^ to a power Concatenates & (or +) two strings
  • 25.
    Concatenation The concatenation operatorjoins one string to the end of another.
  • 26.
    Take note ofthe following code: strFullName = lblFirstName & “ “ & lblLastName