1 / 6

VB Math

VB Math. All of your favorite mathematical operators are available in VB: + Addition - Subtraction * Multiplication / Division Integer Division Mod Modulo (remainder after integer division) ^ Exponentiation. Other Math Functions.

kylene
Download Presentation

VB Math

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. VB Math • All of your favorite mathematical operators are available in VB: • + Addition • - Subtraction • * Multiplication • / Division • \ Integer Division • Mod Modulo (remainder after integer division) • ^ Exponentiation

  2. Other Math Functions • Trig functions, logarithms, and other advanced math functions are available in the Math class (built in to VB). • To use these, just type the word “Math” followed by a period into your code; all of your options will appear in the intellisense drop-down list.

  3. String Operator • VB strings are powerful and easy to use. • A string variable can hold extremely long strings (millions of characters). • The basic string operator is the ampersand (&). It concatenates (puts together) two strings: Dim s As String = “Go “ Dim t As String = “Blue!” Dim u As String = s & t u will have the value “Go Blue!”

  4. String Functions • VB.NET offers many useful string functions • Most can be accessed simply by typing a period after a string variable:

  5. String Functions • Some of the most useful string functions are: • Length: how many characters in the string • Contains: Boolean indicating if one string is inside another • IndexOf: If one string is inside another, this tells you where it begins • StartsWith, EndsWith: Boolean indicating whether one string begins or ends with another • Insert, Remove, Replace: Common editing functions • Substring: Pulls out a part of a string starting with a given character • Split: Takes a string and creates an array of strings which are the original string divided up at a given character (like spaces for words or periods for sentences). • ToUpper, ToLower: Converts the string’s case.

  6. Shortcut assignment operators • VB.NET supports shortcut operators (+=, -=, *=, /=, &=, etc.): • A += B is the same as A = A + B • X *= 4 is the same as X = X * 4 • S &= “!” is the same as S = S & “!”

More Related