1 / 17

Creation of Variables with Numeric, alphanumeric, date, picture, memo data types Constant

Creation of Variables with Numeric, alphanumeric, date, picture, memo data types Constant - A quantity that does not change during the execution of a program is called constant. Constant types are 1) Numeric constant 2) String constant

denver
Download Presentation

Creation of Variables with Numeric, alphanumeric, date, picture, memo data types Constant

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. Creation of Variables with Numeric, alphanumeric, date, picture, memo data types Constant - A quantity that does not change during the execution of a program is called constant. Constant types are 1) Numeric constant 2) String constant • Numeric constant : It is nothing but number. Number can be expressed as integer quantities (whole number) or as decimal quantities (number with decimal point) example : 124 23.55 1299 -345 -45.78 • String constant: A string is a sequence of characters (ie letters, numbers and special symbols such as + , - ,@, $ etc) example: “RAJA” “JAMES BOND 007” “1234$”

  2. Variable - A quantity that does change during the execution of a program is called variable. A variable is a data name that may be used to store a data value. - The address of the memory location is called variable. Rules :- - First character must be a letter - Maximum length of variable name is 255 characters. - The variable name should not be a Keyword. - It can contain only letters, numbers or the underscore character Ex : area, Area, AREA, sum, sum1, net_amount Variable types are 1) Numeric variable 2) String variable. • Numeric variable : It is the address of memory location that can hold only numeric constant. example : x = 124 net_amount = 23.55 sum1 = 1299 z = -45.78 • String constant: It is the address of memory location that can hold only string constant. example: a = “RAJA” name = “JAMES BOND 007” y = “1234$”

  3. Data Types • Every application or program needs to process some data to generate the required output. • All these data values need to be of different types. • It can be classified into two types 1) Fundamental data types  Which is already defined by developer 2) User defined data  Which are created (or defined) by the user at the time of program or application writing . • Fundamental data types: VB provides the following fundamental data types are: • Byte • Boolean • Integer • Long • Single • Double • Currency • Object • Date • String • Variant

  4. Boolean data, represents data that can take only two values. These values are represented as either true or false. • Variant is the default data type in VB. If the data type is not specified to a variable, then the variable is said to have variant data type. Declaration of Variables: (DIM statement ) • VB allows you to declare and store values in variables. Syntax: DIM <variable name > [As <data type>] Examples: DIM name as string DIM id as integer DIM dob as date DIM sex as Boolean Example DIM name Here variable name is variant data type and can store any data suppose name = “Rama”  here name is a string type variable name = 125  here name is a integer type variable name = True  here name is a Boolean type variable name = 77.8  here name is a double type variable

  5. Operators1) Arithmetic Operators

  6. Hierarchy of Arithmetic operators • VB performs math calculations in strict order. The following image illustrates the order of operations

  7. 2) Comparison Operators (conditional /Relational)

  8. 3) Logical Operators

  9. The Assignment Statement Once a variable is declared, it is ready to use. You store values in variables using the assignment statement( = is a assignment operator) . Here is the format for the assignment statement: ItemName = constant / expression/ control’s propery ItemName can be a variable or a control property value. Here are examples of each in respective order: X = 10 sum = a * 0.14 / 2 Name =“Rajive” Label1.caption = “Enter First number”

  10. MsgBox: It is one of the function. It is used to display customized messages to the users. Syntax: Variable = MsgBox(Prompt [,buttons][,title][,helpfile,context]) Here Prompt  is the message that is displayed Button  determine the type of buttons,

  11. Message title  refers to the title of the message box. Ex: choice = MsgBox ( “Are you ready to print ?” , VbOkCancel,”Killikulam” ) Title Buttons Or choice = MsgBox ( “Are you ready to print ?” , 1,”Killikulam” )

  12. Ex : 2 s = 100 MsgBox ("The sum " & Str(s))

  13. Input Box: • This function displays a message box and allows the user to enter a value that your program can respond to. • An input box is simply a message box with a field in which the user can type a value, such as a word or phrase that might answer a question you ask. • Unlike message boxes, you cannot control which command buttons appear in an input box and you cannot place an icon in it as well. • Syntax: Variable = InputBox (Prompt [, Title] [,Default] [,xpos][,ypos]) Here Prompt  is the message that is to be displayed Title  is the title of the Input box message box xpos, ypos  are the position where the InputBox is to be displayed. Ex:1 r = InputBox("Enter Radius", "Killikulam")

  14. s = InputBox("Enter Your Sex", "Killikulam", "Mail")

  15. Design a VB form to find area of circle Private Sub Command1_Click() Dim r As Double Dim area As Double r = InputBox("Enter Radius", "Killikulam") area = 3.14 * Val(r) * Val(r) MsgBox ("The area of Circle = " & area) End Sub

More Related