60 likes | 210 Vues
This document dives into the fundamental concepts of expressions and operators in VB.NET, a powerful programming language. You'll learn about operator types, including arithmetic, string concatenation, assignment, comparison, logical, and object operators. We also discuss operator precedence, which dictates the order of operations in expressions, as well as operator overloading for custom behavior. Key points include how operands can be literals, variables, or return values from functions, and best practices for using parentheses to avoid calculation errors. Perfect for aspiring developers!
E N D
Visual Basic.NET – Expression DanOperator Rully Yulian MF MCAD,MCPD,MCT,MVP VB.NET Independent IT Trainer - Application Developer http://www.yulianmf.com rully@yulianmf.com
Overview • Expression • Operator • Operator Precedence • Operator Overloading
Expression • Kumpulan dari operand dan operator • Operand dapat berupa nilai literal, variabel, atau return value dari sebuah fungsi • Operator menspesifikasikan operasi yang dilakukan terhadap satu atau lebih operand
Operator • Arithmetic • +, -, *, /, \, Mod • String Concatenation • &, + • Assignment • =, +=, -=, *=, /=, &=, \=, ^= • Comparison • =, <, >, <=, >=, <> • Object • Is, IsNot, TypeOf, AddressOf, GetType • Logical • And, AndAlso, Or, OrElse, Not
Operator Precedence • Urutan operator yang di proses dalam sebuah expression • Gunakan tanda kurung () untuk menghindari kesalahan perhitungan • Urutan operator yang di proses : • ^ • - (Negasi) • *, / • \ (Pembagian Integer) • +, - • & (String Concatenation)
Operator Overloading • Bekerja pada Reference Type • Two Objects Added? Multiplied? Compared? • Harus dideklarasikan dengan Shared keyword • Public Shared [otherModifiers] Operator operatorSymbol _ (ByVal operand1 As dataType[, ByVal operand2 As dataType]) _ As returnDataType ' ----- Code Statement End Operator