Skip to main content

  | मौसम…

411 समाचार
Public archive edition · Attributed source reporting with original dates · AI drafts are excluded

411 REFERENCE · Wikibooks

Guide to Game Development/The Programming Language/VB.NET/Basic math operators and Concatenation

Reference material by Wikibooks contributors. This retains its source identity and is not 411 news reporting.

Guide to Game Development/The Programming Language/VB.NET Basic math operators and Concatenation Variables If Statement The four basic math operations The four basic operations can be used between: two constants, a variable and a constant and two variables. + - * / Examples: Dim Num1, Num2, Num3 as Integer Num2 = 10 Num3 = 4 Num1 = Num2 + Num3 Console.WriteLine(Num1) Num1 = 10-5 Console.WriteLine(Num1) Num1 = Num2 * 3 Console.WriteLine(Num1) Num1 = 12 / Num2 Console.WriteLine(Num1) This code could be condenced to not need a Num1 like so: Dim Num2 as Integer = 10 Dim Num3 as Integer = 4 Console.WriteLine(Num2 + Num3) Console.WriteLine(10-5) Console.WriteLine(Num2 * 3) Console.WriteLine(12 / Num2) Output: 14 5 30 3 Powers Powers can be done by the symbol ^ Example use: Console.WriteLine(2^10) Output: 1024 Other mathematical operators For additional math operators, click here. String Concatenation This is the joining of two strings to make one. To do this you can either use + or &. Example of joining two strings: Dim Str1 as String = "Hello " & "World" + "!" Console.WriteLine(Str1) Console.WriteLine("Hello " & "World" + "!") Output: Hello World! Hello World! You can also do this with numbers and strings: Dim Num1 as Integer = 6 Dim Str1 as String = "Your number: " & Num1 & " + 4 = " & Num1 + 4 Console.WriteLine(Str1) Output: Your number 6 + 4 = 10 References 100%