Vb.Net 01 To 03 Summary Upload

Loading...

Flash Player 9 (or above) is needed to view presentations.
We have detected that you do not have it on your computer. To install it, go here.

0 comments

Post a comment

    Post a comment
    Embed Video
    Edit your comment Cancel

    Favorites, Groups & Events

    Vb.Net 01 To 03 Summary Upload - Presentation Transcript

    1. Week 1 – 3 Recap
      • Useful links/info:
      • TPITVB.blogspot.com
    2. VB.NET Week 1
      • Outline:
      • Introduction
      • Simple walk through
      • Coding Conventions
    3. Coding Conventions
      • All keywords – Start with Capital
      • Example: Dim As Integer String Boolean
      • If Then Else ElseIf End If
      • Select Case Case End Select
      • All variable name – Start with small letter
      • Example: i x y nameOfVariable existingString
      • total sumOfNumber
    4. VB.NET Week 2
      • Outline:
      • Variables
      • Strings
      • Operators
      • Maths helper functions
      • Application: Create a Calculator for addition
    5. Variables - Declaring
      • Declare a variable using the Dim and As keywords:
        • Dim sumOfNumber As Integer
        • Name of variable: sumOfNumber
        • Type: Integer
      • (Dim: Short for dimension)
    6. Variables - Declaring
      • Data Type Summary
      Single: single-precision decimal (floating point) Double: double-precision decimal True, False Boolean 8 bytes to store date and time Date 8 bytes to store decimals (others: Single, Decimal) Double 4 bytes to store whole number (others: Short, Long) Integer word or sentence (for just one character: Char) String
    7. Java
      • 8 primitive types:
        • b yte
        • s hort
        • i nt
        • l ong
        • f loat
        • d ouble
        • b oolean
        • c har
      • S tring – not primitive type
    8. Variables - assigning
      • Assign a value to your variable with the = sign, which is sometimes called the assignment operator
        • sumOfNumber = 42
        • This line of code takes the value 42 and stores it in the previously declared variable named sumOfNumber
        • The equals sign is not actually an equals sign.
        • The = sign here means assign a value of .
    9. Variables - assigning
      • Declaring and Assigning Variables with a Default Value
        • Dim sumOf Number As Integer = 0
        • Dim nameOfPerson As String = "None"
    10. Arithmetics Operators Division / Multiplication * Subtraction - Addition +
    11. Other Arithmetic Operators
      • ^ to the power of
      • mod remainder after division (Java:%)
      • division but return only integer portion
      • Short cut:
      • += x += y same as x = x + y
      • -= x -= y same as x = x - y
      • *= x *= y same as x = x * y
      • /= x /= y same as x = x / y
    12. Do not have these operators
      • Java
      • ++
      • - -
    13. Comparison Operators Comparison operators are used to in condition Eg If (condition) doSomthing 4 <> 4 (false) 4 <> 5 (true) 5 <> 4 (true) <> (not equal to) 4 = 4 (true) 4 = 5 (false) 5 = 4 (false) = (equals) Examples Operator
    14. Comparison Operators 4 < 4 (false) 4 < 5 (true) 5 < 4 (false) < (less than) 4 > 4 (false) 4 > 5 (false) 5 > 4 (true) > (greater than) Examples Operator
    15. Comparison Operators 4 <= 4 (true) 4 <= 5 (true) 5 <= 4 (false) <= (less than or equal to) 4 >= 4 (true) 4 >= 5 (false) 5 >= 4 (true) >= (greater than or equal to) Examples Operator
    16. Conversion from String to other types Use CType if you are not sure the name of the conversion function Example: to convert to Boolean CType(variableName, Boolean)
    17. Type Conversion examples
      • Dim inputString As String = TextBox1.Text
      • Dim x As Integer
      • x = CInt (inputString) ' Convert to Integer.
      • Dim y As Integer = 8
      • Textbox1.Text = CStr (y) ' Convert to String.
      c i n t c s t r
    18. Maths Functions
      • Math.Sqrt(n): Return the square root of n.
      • Math.Abs(n): Return the absolute value of n.
      • Math.Sign(n): Return the sign of n ( -1, 0 or +1 ).
      • Example:
      • Dim x As Integer
      • Dim y As Integer = 25
      • TextBox1.Text = Math.Sqrt( y )
      • ‘ MsgBox( &quot;Sq root of 25 is &quot; & CStr(x) )
    19. Class vs Local variables
      • Public Class Form1
      • Dim x As Integer = 0 ' Class variables.
      • Dim name As String = &quot;&quot;
      • Sub Button0_Click …
      • Dim y As Integer = 9 ' Local sub variables.
      • End Sub
      • :
      • End Class
      x = 5 ' OK or Not? y = 5 ' OK or Not? x = 5 ' OK or Not? y = 5 ' OK or Not?
    20. VB.NET lesson week
      • Get Input from User
      • If Then Else, Else If
      • Select Case
      • Add condition checking into Simple Calculator
    21. Get Input from User Dim name As String name = InputBox (&quot;Enter your name:&quot;) MsgBox (&quot;Your name is &quot; & name)
    22. If Then Else, Else If
      • Syntax
      • If condition Then
      • :
      • End If
      Else : ElseIf condition2 Then ' Can repeat for : ' more conditions Example If name <> &quot;&quot; Then MsgBox(name) End If Example If name <> &quot;&quot; Then MsgBox(name) Else MsgBox(&quot;Empty&quot;) End If Example If name = &quot;&quot; Then MsgBox(&quot;Empty&quot;) ElseIf name = &quot;me&quot; Then MsgBox(&quot;Me&quot;) Else MsgBox(name) End If
    23. More than one condition
      • And condition1 And condition2
      • AndAlso condition1 AndAlso condition2
      • Recommended - Short-circuit And
      • Eg If i > 0 AndAlso j <> 5 Then
      Once i > 0 is false, no need to check j <> 5
    24. More than one condition
      • Or condition1 Or condition2
      • OrElse condition1 OrElse condition2
      • Recommended - Short-circuit Or
      • Eg If i > 0 OrAlso j <> 5 Then
      Once i > 0 is true, no need to check j <> 5
    25. Short cut If and Assignment
      • IIf I mmediate If
      • x = IIf( i > 0, 1, 0)
      • Same As
      • If i > 0 Then
      • x = 1
      • Else
      • x = 0
      • End If
    26. Select Case
      • Syntax
      • Select Case variable
      • Case condition1
      • :
      • Case condition2
      • :
      • Case Else
      • :
      • End Select
      Example Select Case name Case &quot;&quot; MsgBox(&quot;Empty&quot;) Case &quot;Me&quot; MsgBox(&quot;me&quot;) Case Else MsgBox(name) End Select
    27. Select Case Conditions
      • Case &quot;red&quot;, &quot;white&quot;, &quot;green&quot; ' A few together .
      • Case 1 To 10 ' A range using
      • ' keyword To .
      • Case Is > 9 ' A range using
      • ' keyword Is .
    28. Java
      • if (condition) {
      • :
      • } else if (condition 2) {
      • } else {
      • :
      • }
      switch variable { case 1: : break; case 2: : break; default: : }
    29. End of lessons
    SlideShare Zeitgeist 2009

    + puahhlsspuahhlss Nominate

    custom

    86 views, 0 favs, 2 embeds more stats

    Vb.Net 01 To 03 Summary Upload

    More info about this document

    © All Rights Reserved

    Go to text version

    • Total Views 86
      • 70 on SlideShare
      • 16 from embeds
    • Comments 0
    • Favorites 0
    • Downloads 3
    Most viewed embeds
    • 15 views on http://tpitvb.blogspot.com
    • 1 views on http://www.tpitvb.blogspot.com

    more

    All embeds
    • 15 views on http://tpitvb.blogspot.com
    • 1 views on http://www.tpitvb.blogspot.com

    less

    Flagged as inappropriate Flag as inappropriate
    Flag as inappropriate

    Select your reason for flagging this presentation as inappropriate. If needed, use the feedback form to let us know more details.

    Cancel
    File a copyright complaint
    Having problems? Go to our helpdesk?

    Categories