1 / 14

Comment

prentice
Download Presentation

Comment

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. VB Code Statements3 types of VB statementThe Remark statement, known as comments, are used for project documentation only Begin with an apostropheNot executableComments make the project more readable and understandableThe inclusion of comments is seen as good programming practiceIt is a good idea to comment within the logic of the project, especially if the purpose of any statement is unclear

  2. The Assignment statement assigns a value to a property or variableAssignment statements operate form Right to Left, that is the value appearing on the right hand side of the equal sign (=) is assigned to the property named on the left of the equal sign(Example: lblTitle.FontSize = 12Let lblTitle.FontSize = 12)The use of ‘Let’ is optional, and its use may improve the readability of the project code

  3. When the value to assign is ‘actual text’, known as a Literal, it is enclosed in quotation marksThis allows any combination of alpha and numeric characters to be typedHowever, if the value is numeric, (eg: 12), do not enclose it in quotation marksDo not place quotation marks around the term True or False, as VB recognises these as Special Key Terms (Blue in colour, within VB code)The End statement stops the execution of the project

  4. Private Sub cmdPush_Click ‘Display the ‘Hello World’ Message lblMessage.Caption = “Hello World”End Sub***********************************************Private Sub cmdExit_Click ‘Exit the project EndEnd Sub Comment Assignment

  5. To type the VB code behind the command button (named cmdPush), Double-Click on the Push Me (caption) command buttonAs a result the Visual Basic Code Window will open, with the First and Last lines of the Sub Procedure already in place, by default within VBFollow good coding conventions and Indent all lines between Private Sub and End Sub

  6. Label Caption Property A Label control’s caption size is unlimited. For forms and all other controls that have captions, the limit is 255 characters.

  7. Variables: Memory locations that hold data, that can be changed during project execution(eg: student names will vary as the information for each student is being processed)Constants: Memory locations that hold data that cannot change during execution(eg: however, the college which the students attend (UCC) will remain the same) Variables and Constants

  8. Variables are declared, depending on where they are used and how long their value needs to be retainedVariables are locations in the computers memory, which are named by the user Variables store valuesThe values which are assigned to variables can change during project execution (the values they hold varies, hence the name) Variables

  9. Variables have to be declared (the computer must be made aware of their existence) and once they have been declared, the computer allocates them (memory) storage space and assigns this area of memory a name, called an identifierVariables are declared using the DIM statementDIM Variable Name (Identifier)AS Data TypeThe declaration statements establish the project variables, assign names to the variables, and specify the type of data that the variables will holdThe statements are non-executable (they are not executed in the flow of instructions during program execution

  10. Dim stName As STRING (Declares a string variable)Dim iCounter As INTEGER (Declares an integer variable)The reserved word DIM is short for dimension, meaning sizeVariables can have a number of different data typesA variable can only store values which correspond with the data type they are assigned

  11. Data Types The data type of a variable indicates what type of information will be stored in the allocated memory spaceThe default data type is variantThe advantage of using variant data type is that it is easy, and the variables change their appearance as needed for each situationThe disadvantage is that variants are less efficient than the other data types, they require more memory and operate less quickly

  12. DIM Variable name (Identifier) AS Data TypeDim iYear As IntegerDim stCustName As Stringcan also be declared as:Dim iYear As Integer, stCustName As StringAlso Specific Characters can be used to represent eachof the Data Types Variable Declarations

  13. - String ($) - Integer (%) - Currency (@) - Long Integer (&) - Single Precision (!) - Double Precision (£)Variable Declarations Dim iYear%, stCustName$, cInterest@ Data Types

More Related