51 views

Uploaded by nazeer.pasha

Attribution Non-Commercial (BY-NC)

- ALV Programming Guide
- B VBScript07
- B VBScript02
- B VBScript05
- ACS850 ACQ810 Appl Programming Appl Guide B
- Ex 2
- B VBScript11
- B VBScript03
- piglatin_ref2
- B VBScript04
- B VBScript06
- B VBScript08
- B VBScript10
- B VBScript01
- S7 Calculation Functions
- Variables Guide
- 20761B_06
- Learn PHP In A Day
- c++ practicals Programs
- Additional Data Blending Topics

You are on page 1of 26

Session 9

Dani Vainstein 1

What we learn last session?

Code convention usage for

constants, variables, objects and

functions.

Dani Vainstein 2

Subjects for session 9

Conversion functions.

OS Conversions

Asc, Char

Data Types conversions

CBool, CByte, CCur, CDate, CDbl, Char, CInt, Clng,

CSng, CStr

Base Conversions

Hex, Oct

IsArray, IsDate, IsEmpty, IsNull, Is Numeric, IsObject

Dani Vainstein 3

Conversion Functions

OS Conversions - Asc

the first letter in a string.

The string argument is any valid string

expression. If the string contains no characters, a

run-time error occurs.

Dani Vainstein 4

Conversions Functions - Char

specified ANSI character code.

The charcode argument is a number that

identifies a character.

Numbers from 0 to 31 are the same as standard,

nonprintable ASCII codes.

For example, Chr(10) returns a linefeed

Dani Vainstein 5

Conversion Functions

Data Type Conversions - CBool

Variant of subtype Boolean.

If expression is zero, False is returned; otherwise, True is

returned.

If expression can't be interpreted as a numeric value, a run-

time error occurs.

Dani Vainstein 6

Conversion Functions

Data Type Conversions - CByte

In general, you can document your code using the subtype conversion functions

to show that the result of some operation should be expressed as a particular

data type rather than the default data type.

For example, use CByte to force byte arithmetic in cases where currency, single-

precision, double-precision, or integer arithmetic normally would occur.

Use the CByte function to provide internationally aware conversions from any

other data type to a Byte subtype.

For example, different decimal separators are properly recognized depending on

the locale setting of your system, as are different thousand separators.

Dani Vainstein 7

Conversion Functions

Data Type Conversions - CCur

subtype Currency

In general, you can document your code using the subtype

conversion functions to show that the result of some operation

should be expressed as a particular data type rather than the

default data type.

For example, use CCur to force currency arithmetic in cases where

integer arithmetic normally would occur.

You should use the CCur function to provide internationally aware

conversions from any other data type to a Currency subtype.

Dani Vainstein 8

Conversion Functions

Data Type Conversions - CDate

Date.

Use the IsDate function to determine if date can be converted to a date or

time.

CDate recognizes date literals and time literals as well as some numbers

that fall within the range of acceptable dates.

When converting a number to a date, the whole number portion is

converted to a date.

CDate recognizes date formats according to the locale setting of your

system.

The correct order of day, month, and year may not be determined if it is

provided in a format other than one of the recognized date settings.

In addition, a long date format is not recognized if it also contains the day-

of-the-week string.

Dani Vainstein 9

Conversion Functions

Data Type Conversions - CDate

Double.

In general, you can document your code using the subtype conversion

functions to show that the result of some operation should be expressed as

a particular data type rather than the default data type.

For example, use CDbl or CSng to force double-precision or single-

precision arithmetic in cases where currency or integer arithmetic normally

would occur.

Use the CDbl function to provide internationally aware conversions from

any other data type to a Double subtype.

For example, different decimal separators and thousands separators are

properly recognized depending on the locale setting of your system.

Dani Vainstein 10

Conversion Functions

Data Type Conversions - CInt

Variant of subtype Integer.

In general, you can document your code using the

subtype conversion functions to show that the result of

some operation should be expressed as a particular data

type rather than the default data type.

For example, use CInt or CLng to force integer arithmetic

in cases where currency, single-precision, or double-

precision arithmetic normally would occur.

Use the CInt function to provide internationally aware

conversions from any other data type to an Integer

subtype.

If expression lies outside the acceptable range for the

Integer subtype, an error occurs.

Dani Vainstein 11

Conversion Functions

Data Type Conversions - CLng

Variant of subtype Long.

For example, use CInt or CLng to force integer arithmetic

in cases where currency, single-precision, or double-

precision arithmetic normally would occur.

Use the CLng function to provide internationally aware

conversions from any other data type to a Long subtype.

For example, different decimal separators are properly

recognized depending on the locale setting of your

system, as are different thousand separators.

If expression lies outside the acceptable range for the

Long subtype, an error occurs.

Dani Vainstein 12

Conversion Functions

Data Type Conversions - CSng

Variant of subtype Single.

For example, use CDbl or CSng to force double-precision

or single-precision arithmetic in cases where currency or

integer arithmetic normally would occur.

Use the CSng function to provide internationally aware

conversions from any other data type to a Single

subtype.

For example, different decimal separators are properly

recognized depending on the locale setting of your

system, as are different thousand separators.

If expression lies outside the acceptable range for the

Long subtype, an error occurs.

Dani Vainstein 13

Conversion Functions

Data Type Conversions - CStr

converted to a Variant of subtype String.

Use the CStr function to provide

internationally aware conversions from any

other data type to a String subtype.

You should use the CStr function instead of

Str to provide internationally aware

conversions from any other data type to a

String subtype.

Dani Vainstein 14

Conversion Functions

Data Type Conversions - CStr

according to the following

If expression is Boolean then CStr returns a string

containing True or False.

If expression is Date then CStr returns a string

containing a date in the short-date format of your system.

If expression is Null then CStr returns a run-time error.

If expression is Empty then CStr returns a zero-length

String ("").

If expression is Error then CStr returns a string

containing the word Error followed by the error number.

If expression is Other Numeric then CStr returns a string

containing the number.

Dani Vainstein 15

Conversion Functions

Base Conversions - Hex

If number is not already a whole number, it is rounded to the

nearest whole number before being evaluated.

If number is Null then Hex returns Null.

If number is Empty then Hex returns Zero(0).

If number is any other number then Hex returns Up to 8 hexadecimal

characters.

You can represent hexadecimal numbers directly by preceding

numbers in the proper range with &H.

For example, &H10 represents decimal 16 in hexadecimal notation.

Dani Vainstein 16

Conversion Functions

Base Conversions - Oct

If number is not already a whole number, it is rounded to the

nearest whole number before being evaluated.

If number is Null then Oct returns Null.

If number is Empty then Oct returns Zero(0).

If number is any other number then Oct returns Up to 11 octal

characters.

You can represent octal numbers directly by preceding numbers in

the proper range with &O.

For example, &O10 is the octal notation for decimal 8.

Dani Vainstein 17

Variables Subtypes

Verification

VB provides a set of critical data varification functions.

IsArray - IsArray(varname)

Returns a Boolean value indicating whether a variable is an

array.

The varname argument can be any variable.

IsArray returns True if the variable is an array; otherwise,

it returns False.

IsArray is especially useful with variants containing arrays.

Dani Vainstein 18

Variables Subtypes Verification

IsDate Function

can be converted to a date.

The expression argument can be any date expression or

string expression recognizable as a date or time.

IsDate returns True if the expression is a date or can be

converted to a valid date; otherwise, it returns False.

In Microsoft Windows, the range of valid dates is January 1,

100 A.D. through December 31, 9999 A.D.

Ranges vary among operating systems.

Dani Vainstein 19

Variables Subtypes Verification

IsEmpty Function

has been initialized.

However, because IsEmpty is used to determine if

individual variables are initialized, the expression

argument is most often a single variable name.

IsEmpty returns True if the variable is uninitialized, or

is explicitly set to Empty; otherwise, it returns False.

False is always returned if expression contains more

than one variable.

Dani Vainstein 20

Variables Subtypes Verification

IsNull Function

Returns a Boolean value that indicates whether an expression contains no valid data

(Null).

IsNull returns True if expression is Null, that is, it contains no valid data; otherwise,

IsNull returns False.

If expression consists of more than one variable, Null in any constituent variable

causes True to be returned for the entire expression.

The Null value indicates that the variable contains no valid data.

Null is not the same as Empty, which indicates that a variable has not yet been

initialized.

It is also not the same as a zero-length string (""), which is sometimes referred to as

a null string.

Caution Use the IsNull function to determine whether an expression contains a

Null value.

Expressions that you might expect to evaluate to True under some circumstances,

such as If Var = Null and If Var <> Null, are always False.

This is because any expression containing a Null is itself Null, and therefore, False.

Dani Vainstein 21

Variables Subtypes Verification

IsNumeric Function

expression can be evaluated as a number.

The expression argument can be any expression.

IsNumeric returns True if the entire expression is

recognized as a number; otherwise, it returns False.

IsNumeric returns False if expression is a date

expression.

Dani Vainstein 22

Variables Subtypes Verification

IsObject Function

whether an expression references a

valid Automation object.

IsObject returns True if expression is

a variable of Object subtype or a user-

defined object; otherwise, it returns

False.

Dani Vainstein 23

Lab 9.1

In a company we have 3 divisions : “HR”,”R&D” and

“QA”

Each employee in each division, will asked by his

name and Salary (Input box) title of input boxes the

division name.

The program will loop in a fixed for…next statement

(for divisions).

Employees will be entered in another loop,

# of employees in each division = unknown.

The default salary is 2800 NIS.

Verify if the entered value for salary is a number,

otherwise display a warning message + warning

icon, and downgrade to zero.

Use only two arrays.

Dani Vainstein 24

Lab 9.1

Write a Sub procedure that outputs to the reporter the

percenatge of taxes paid by each employee according to the

follow tax table

Until 2800 NIS – 0%

Between 2801 And 3500 NIS – 10%

Between 3501 And 4500 NIS – 20%

Between 4501 And 6500 NIS – 30%

Between 6501 And 9500 NIS – 40%

Between 9501 And 12000 NIS – 50%

Between 12001 And 15000 NIS – 55%

15001 and above – 60%

The calculation Itself will be calculated in the function

GetTax(curSal).

Tips :

Use the Erase statement to reuse the arrays.

Convert to subtype currency.

Dani Vainstein 25

Check if input size is > 0 before enter sub.

Make sure to visit us

Tutorials

Articles

Proikects

And much more

www.AdvancedQTP.com

26

- ALV Programming GuideUploaded byBipin Shukla
- B VBScript07Uploaded bynazeer.pasha
- B VBScript02Uploaded byjohnson manesh
- B VBScript05Uploaded byjohnson manesh
- ACS850 ACQ810 Appl Programming Appl Guide BUploaded bygiriktvr
- Ex 2Uploaded byChidambaram
- B VBScript11Uploaded bynazeer.pasha
- B VBScript03Uploaded bynazeer.pasha
- piglatin_ref2Uploaded byPankaj Kumar
- B VBScript04Uploaded bynazeer.pasha
- B VBScript06Uploaded bynazeer.pasha
- B VBScript08Uploaded bynazeer.pasha
- B VBScript10Uploaded bynazeer.pasha
- B VBScript01Uploaded bynazeer.pasha
- S7 Calculation FunctionsUploaded byplim5oll
- Variables GuideUploaded byCinthia Lidia Hidrogo Paulino
- 20761B_06Uploaded byAbdul-alim Bhnsawy
- Learn PHP In A DayUploaded byRaglean Cristian
- c++ practicals ProgramsUploaded byPoonam Gupta
- Additional Data Blending TopicsUploaded bysamyuktha_subramania
- Java AsserionsUploaded bykasim
- ds and alogUploaded byAnonymous K07EYjy
- Data DictionaryFinal (AutoRecovered)Uploaded byrakesh
- Ch1036465apter 2Uploaded byida hadi
- cUploaded byAman Roy
- Think Twice Code Once _bt9Uploaded byNelson Picones
- Marketing Chapter 22Uploaded byMohammed Abdul Sami
- Add Client NewUploaded bykrudmin
- Computer Programming Lecture 2Uploaded byRaja Mustafa
- How Do You Create and Parameterize Variables and the in, OUT and IN_OUT Parameters of TheUploaded byAbez Five

- Time Series R DocumentationUploaded byAbhee Raj
- 00718a - Brush-DC Servomotor Implementation Using PIC17C756AUploaded byadisaks
- English for Emails - 2016Uploaded bysalem
- Irregular VerbsUploaded byAna Garcia
- W7 SolutionsUploaded byjohn smither
- NTPC_UNIT-1_RSTPS_CALLBRATION_Report.docUploaded byRajeevAgrawal
- Traffic Jam Preventor on Over BridgeUploaded bySandeep Akurathi
- Phrasal VerbsUploaded byEmir XH
- Semiotics of Classical MusicUploaded byAndrea Ceballos
- EmmaUploaded byMengyin He
- FX 485PC if User's ManualUploaded byNguyen Hien
- IM-Ch15-DB-Connectivity-Web-Technologies-Ed12.docxUploaded byMohsin
- TMS TPLANNER.pdfUploaded bywilker
- SQL Study Guide 9 & 10Uploaded byMatthew N Michelle Bondoc
- SAP Business Planning and Consolidation for NetWeaver - Journals.pdfUploaded byAnndyChirica
- multipassaasemblerUploaded byBala Jai
- SCRA 2014 Mathematics PaperUploaded byAryan Classes
- fsl programsUploaded byapi-263088012
- CIRATS_Health Check DeviationsUploaded byRogério Bertoni
- The Ricciardi LetterUploaded byListillo
- JAVA-02a Array UpdatedUploaded byIhsan Abdullah
- HortatoryUploaded bySaoriShibasawa
- aleister-crowley-selected-poems[1].pdfUploaded byRoberto Migliussi
- Latest Dot Net Interview Questions and AnswersUploaded byMikky James
- Cantor User ManUploaded byAnonymous WvxkIa
- ME PED LABUploaded byBalasubramani
- DsPIC Programmers Reference 70157CUploaded byEce Ozarici
- T24 Technical Presentation 2013 v8 UpdateUploaded byadnanbw
- Classical Notes Debussy - Pelleas Et Melisande, By Peter GutmannUploaded byAnto Nella
- writing lesson plan draft 2Uploaded byapi-284932576