Visual Basic Language: Data Conversion, String Handling, and Operators

unit i chapter 2 n.w
1 / 27
Embed
Share

Discover the capabilities of Visual Basic language with insights on data conversion functions, string handling techniques, arithmetic and assignment operators, as well as relational expressions. Learn how to manipulate strings, convert data types, perform calculations, and compare values efficiently in Visual Basic.

  • Visual Basic Language
  • Data Conversion
  • String Handling
  • Operators
  • Programming

Uploaded on | 0 Views


Download Presentation

Please find below an Image/Link to download the presentation.

The content on the website is provided AS IS for your information and personal use only. It may not be sold, licensed, or shared on other websites without obtaining consent from the author. If you encounter any issues during the download, it is possible that the publisher has removed the file from their server.

You are allowed to download the files provided on this website for personal or commercial use, subject to the condition that they are used lawfully. All files are the property of their respective owners.

The content on the website is provided AS IS for your information and personal use only. It may not be sold, licensed, or shared on other websites without obtaining consent from the author.

E N D

Presentation Transcript


  1. UNIT I CHAPTER 2 THE VISUAL BASIC LANGUAGE

  2. VISUAL BASIC DATA CONVERSION FUNCTIONS To convert Use this Character code to character Chr String to lowercase or uppercase Format, LCase, UCase, String.ToUpper, String.ToLower, String.Format Date to a number DateSerial, DateValue Decimal number to other bases Hex, Oct Number to string Format, Str One data type to another CBool, CByte, CDate, CDbl, CDec, CInt, CLng, CObj, CSng, CShort, CStr, Fix, Int Character to character code Asc String to number Val Time to serial number TimeSerial, TimeValue

  3. STRING HANDLING To do this Use this Concatenate two strings &, +, String.Concat, String.Join Compare two strings StrComp, String.Compare, String.Equals, String.CompareTo Convert strings StrConv, CStr, String. ToString Copying strings =, String.Copy Convert to lowercase or uppercase Format, Lcase, Ucase, String.Format, String. ToUpper, String. ToLower Convert to and from numbers Str, Val.Format, String.Format Create string of a repeating character Space, String, String.String Create an array of strings from one string String.Split Find length of a string Len, String.Length Format a string Format, String.Format

  4. Get a substring Mid, String.SubString Insert a substring String.Insert Justify a string with padding LSet, Rset, String.PadLeft, String.PadRight Manipulate strings InStr, Left, LTrim, Mid, Right, RTrim, Trim, String.Trim, String.TrimEnd, String.TrimStart Remove text Mid, String.Remove Replace text Mid, String.Replace Set string comparison rules Option Compare Search strings InStr, String.Chars, String.IndexOf, String.IndexOfAny, String.LastIndexOf, String.LastIndexOfAny Trim leading or trailing spaces LTrim, RTrim, Trim, String.Trim, String.TrimEnd, String.TrimStart Work with character codes Asc, AscW, Chr

  5. ARITHMETIC OPERATORS ^ Exponentiation * Multiplication / Division \ Integer division Mod Modulus +Addition - Subtraction

  6. ASSIGNMENT OPERATORS =Assignment ^= Exponentiation followed by assignment *= Multiplication followed by assignment /= Division followed by assignment \= Integer division followed by assignment +=Addition followed by assignment -= Subtraction followed by assignment &= Concatenation followed by assignment

  7. RELATIONAL < (Less than) True if operand1 is less than operand2 <= (Less than or equal to) True if operand1 is less than or equal to operand2 > (Greater than) True if operand1 is greater than operand2 >= (Greater than or equal to) True if operand1 is greater than or equal to operand2 = (Equal to) True if operand1 equals operand2 <> (Not equal to) True if operand1 is not equal to operand2 Is True if two object references refer to the same object Like Performs string pattern matching

  8. STRING CONCATENATION & String concatenation + String concatenation

  9. LOGICAL And Performs an And operation (for logical operations: True if both operands are True, False otherwise; the same for bit-by-bit operations where you treat 0 as False and 1 as True). Not Reverses the logical value of its operand,from True to False and False to True, for bitwise operations,turns 0 into 1 and 1 into 0. Or Operator performs an Or operation (for logical operations: True if either operand is True, False otherwise; the same for bit-by-bit operations where you treat 0 as False and 1 as True). Xor Operator performs an exclusive-Or operation (for logical operations: True if either operand, but not both, is True, and False otherwise; the same for bit-by-bit operations where you treat 0 as False and 1 as True). AndAlso Operator A "short circuited" And operator; if the first operand is False, the second operand is not tested. OrElse Operator A "short circuited" Or operator, if the first operand is True, the second is not tested.

  10. MISCELLANEOUS AddressOf Gets the address of a procedure. GetType Gets information about a type.

  11. PRECEDENCE Exponentiation (^) Negation (-) (for example, -intValue reverses the sign of the value in intValue) Multiplication and division (*, /) Integer division (\) Modulus arithmetic (Mod) Addition and subtraction (+,-)

  12. NEXT LEVEL String concatenation (+) String concatenation (&)

  13. NEXT LEVEL Equality (=) Inequality (<>) Less than, greater than (<,>) Greater than or equal to (>=) Less than or equal to (<=) Like Is

  14. LAST LEVEL Negation-(Not) Conjunction-(And,AndAlso) Disjunction-(Or, OrElse, Xor)

  15. COMMENTING Rem keyword

  16. IF . ELSE If conditionThen [statements] [ElseIf condition-nThen [elseifstatements] ] [Else [elsestatements]] End If

  17. SELECT CASE Select Case testexpression [Case expressionlist-n [statements-n]] [Case Else [elsestatements]] End Select

  18. LOOPING Do [{While | Until} condition ] [statements] [Exit Do] [statements] Loop or at the end: Do [statements] [Exit Do] [statements] Loop [{While | Until} condition]

  19. FOR LOOP For index = startTo end [Step step] [statements] [Exit For] [statements] Next [index]

  20. FOR EACH For Each element In group [statements] [Exit For] [statements] Next [element]

  21. WHILE While condition [statements] End While

  22. WITH STATEMENT With object [statements] End With For example With TextBox1 .Height = 1000 .Width = 3000 .Text = "Welcome to Visual Basic" End With

  23. DATE FUNCTIONS To do this Use this Get the current date or time Today, Now, TimeofDay, DateString, TimeString Perform date calculations DateAdd, DateDiff, DatePart Return a date DateSerial, DateValue Return a time TimeSerial, TimeValue Set the date or time Today, TimeofDay Time a process Timer

  24. Format Expression Yields this Format(Now, "M-d-yy") "1-1-03" Format(Now, "M/d/yy") "1/1/03" Format(Now, "MM - dd - yy") "01 /01 / 03" Format(Now, "ddd, MMMM d, yyy") "Friday, January 1, 2003" Format(Now, "d MMM, yyy") "1 Jan, 2003" Format(Now, "hh:mm:ss MM/dd/yy") "01:00:00 01/01/03" Format(Now, "hh:mm:ss tt MM-dd-yy") "01:00:00 AM 01-01-03"

  25. MATHEMATICAL FUNCTIONS Old New Visual Basic .NET method Description Abs System.Math.Abs Yields the absolute value of a given number. Atn System.Math.Atan Yields a Double value containing the angle whose tangent is the given number. Cos System.Math.Cos Yields a Double value containing the cosine of the given angle. Exp System.Math.Exp Yields a Double value containing e (the base of natural logarithms) raised to the given power.

  26. Old New Visual Basic .NET method Description Log System.Math.Log Yields a Double value containing the logarithm of a given number. Round System.Math.Round Yields a Double value containing the number nearest the given value. Sgn System.Math.Sign Yields an Integer value indicating the sign of a number. Sin System.Math.Sin Yields a Double value specifying the sine of an angle. Sqr System.Math.Sqrt Yields a Double value specifying the square root of a number. Tan System.Math.Tan Yields a Double value containing the tangent of an angle.

  27. FINANCIAL FUNCTIONS To do this Use this Calculate depreciation DDB, SLN, SYD Calculate future value FV Calculate interest rate Rate Calculate internal rate of return IRR, MIRR Calculate number of periods NPer Calculate payments IPmt, Pmt, PPmt Calculate present value NPV, PV

More Related Content