operators , functions and options in vb.net

28
.NET Operators, Functions ,Optio n Shyam N. Chawda +91 7874391191 1

Upload: shyam-chawda

Post on 22-May-2015

422 views

Category:

Technology


0 download

DESCRIPTION

VB.NET

TRANSCRIPT

Page 1: Operators , Functions and Options in VB.NET

1

.NET

Operators, Functions ,Option

Shyam N. Chawda +91 7874391191

Page 2: Operators , Functions and Options in VB.NET

Shyam N. Chawda 2

Operators An operator is a symbol or other character

indicating an arithmetic operation that acts on one or more elements in an application.

That take one operand are called unary operators.

That take two operands are called binary operators.

Page 3: Operators , Functions and Options in VB.NET

Operators

Arithmetic ^, –, *, /, \, Mod, +

Assignment =, ^=, *=, /=, \=, +=, -=, &=

Comparison/Relational

=, <>, <, >, <=, >=, Like, Is

Concatenation &, +

Logical/bitwise Not, And, Or, Xor, AndAlso, OrElse

Miscellaneous operations

AddressOf, GetType

Page 4: Operators , Functions and Options in VB.NET

Shyam N. Chawda 4

Arithmetic\ is integer division./ is regular division.34 / 2.5 = 13.634 \ 2.5 = 17 (convert 2.5 into 2 then)^ exponent operator.2^4 = 16

Page 5: Operators , Functions and Options in VB.NET

Shyam N. Chawda 5

Assignment

=

Page 6: Operators , Functions and Options in VB.NET

Shyam N. Chawda 6

Comparison / Relational=Dim a, b As Integer a = 5 b = 10

If a = b Thenlogic…….

End If

Page 7: Operators , Functions and Options in VB.NET

Shyam N. Chawda 7

Comparison / Relational

If TypeOf btnIntDiv Is Button Then MsgBox("Hai") End If

Use the TypeOf...Is operator to determine whether a given object:

Is an instance of a given class

Page 8: Operators , Functions and Options in VB.NET

Shyam N. Chawda 8

Comparison / Relational

LikeDefined only for operands of type String.

The result is True if the first operand matches the pattern given in the second operand; False if not.

Page 9: Operators , Functions and Options in VB.NET

Shyam N. Chawda 9

Comparison / Relational

Dim ans As Booleanans = "F" Like "F" ans = "F" Like "f" ans = "F" Like "FFF" ans = "aBBBa" Like "a*a" ans = "F" Like "[A-Z]" ans = "F" Like "[!A-Z]" ans = "a2a" Like "a#a" ans = "aM5b" Like "a[L-P]#[!c-e]"

Page 10: Operators , Functions and Options in VB.NET

Shyam N. Chawda 10

Comparison / Relational

ans = "BAT123khg" Like "B?T*" ans = "CAT123khg" Like "B?T*"

Page 11: Operators , Functions and Options in VB.NET

Shyam N. Chawda 11

Logical /bitwise

AndAlso

Only And?AndAlso performs logical short-circuiting: if

the first operand of the expression is False, the second operand is not evaluated.

b = (93 > 67) AndAlso MyFunction()

Page 12: Operators , Functions and Options in VB.NET

Shyam N. Chawda 12

Logical /bitwiseOrElse

OR ?

OrElse performs logical short-circuiting: if the first operand of the expression is True, the second operand is not evaluated.

Page 13: Operators , Functions and Options in VB.NET

Shyam N. Chawda 13

Multiple statements in one line ( : )

x = 3 : y = 5 : z = 6

One statement in multiple lines ( _ )

name = "Mr." & " " & "Karna" & _ " " & "Bhavin" & " " & _ ", Trivedi"

Page 14: Operators , Functions and Options in VB.NET

Shyam N. Chawda 14

CommentComments are brief explanatory notes

added to code for the benefit of those reading it.

Comment ( )

Uncomment ( )

buttons on the Edit toolbar. REM:

Page 15: Operators , Functions and Options in VB.NET

Shyam N. Chawda 15

Option ExplicitUsed at file level to force explicit

declaration of all variables in that file.

On (Default)Enables Option Explicit checking.

Off Disables Option Explicit checking.

Default - Object type.

Page 16: Operators , Functions and Options in VB.NET

Shyam N. Chawda 16

Option ExplicitOption Explicit On

Dim MyVar As Integer

MyInt = 10

MyVar = 10

Page 17: Operators , Functions and Options in VB.NET

Shyam N. Chawda 17

Option StrictRestricts implicit data type conversions

OnGenerate an error

Off (Default)Compiler default is Option Strict Off if do not specify Option Strict in your code.

Page 18: Operators , Functions and Options in VB.NET

Shyam N. Chawda 18

Option Strict Dim MyVar As Integer

MyVar = 1000

'Attempting to convert to an Integer generates an error.

MyVar = 1234567890.9876542

MsgBox(MyVar)

Page 19: Operators , Functions and Options in VB.NET

Shyam N. Chawda 19

Object data typeDim objDb As Object

when you do not know at compile time what data type the variable might point to.

Can point to data of any data type,

Page 20: Operators , Functions and Options in VB.NET

Shyam N. Chawda 20

Object data typeWhatever data type it refers to, an Object

variable does not contain the data value itself, but rather a pointer to the value.

It always uses four bytes in computer memory, but this does not include the storage for the data representing the value of the variable.

Page 21: Operators , Functions and Options in VB.NET

Shyam N. Chawda 21

Object data typeThe Object data type is slower than using

explicit data types.

The code that uses the pointer to locate the data, Object variables holding value types are slightly slower to access than explicitly typed variables.

Page 22: Operators , Functions and Options in VB.NET

Shyam N. Chawda 22

IMP functions , constants

vbCrLf Carriage return/linefeed character combination.

vbNewLine Newline character. vbTab Tab character.

Page 23: Operators , Functions and Options in VB.NET

Shyam N. Chawda 23

IMP functions , constants

Space(Integer)

InputBox()

MsgBox()

MessageBox.Show()

Val()

Page 24: Operators , Functions and Options in VB.NET

Shyam N. Chawda 24

With…End Withwhen we want to set number of properties

and methods related with one control or object that time use with..end with block.

It executes series of statement related to one control or object

Page 25: Operators , Functions and Options in VB.NET

Shyam N. Chawda 25

With…End WithSyntax:

With objname

end With

Page 26: Operators , Functions and Options in VB.NET

Shyam N. Chawda 26

With…End With

Page 27: Operators , Functions and Options in VB.NET

Shyam N. Chawda 27

With…End WithWith MyLabel .Height = 200 .Width = 200 .Text = "Demo Label"End With

Page 28: Operators , Functions and Options in VB.NET

28

Thanks

Any questions?www.shyamsir.com

Shyam N. Chawda