Saturday, September 17, 2011

Parse Integer

public class Test
   public Shared Sub Main
        Try
            Dim num_items As Integer = Integer.Parse("123")
        Catch ex As Exception
            Console.WriteLine(ex.Message)
        End Try
   End Sub
End class

MinValue and MaxValue of Integer

public class Test
   public Shared Sub Main
               Dim iNum As Integer
               Console.WriteLine("Integer: " & iNum.MinValue & " to " & iNum.MaxValue)
   End Sub
End class

Swap two integers without using a third

Imports System.Drawing
Imports System.Drawing.Drawing2D
Imports System.Collections
Public Class Tester
    Public Shared Sub Main
        
        Dim firstValue As Integer
        Dim secondValue As Integer

        firstValue = 17
        secondValue = 123
        Console.WriteLine("Before swap: {0}, {1}",firstValue, secondValue)

        firstValue = firstValue Xor secondValue
        secondValue = firstValue Xor secondValue
        firstValue = firstValue Xor secondValue
        Console.WriteLine("After swap: {0}, {1}",firstValue, secondValue)
    End Sub
End Class

Integer calculation

public class Test
   public Shared Sub Main
        Dim As Integer

        ' try adding numbers...
        n = 16
        n += 10.23
        Console.WriteLine("Addition " & n)

        ' try subtracting numbers...
        n = 24
        n -= 2
        Console.WriteLine("Subtraction " & n)

        ' try multiplying numbers...
        n = 6
        n *= 10
        Console.WriteLine("Multiplication " & n)

        ' try dividing numbers...
        n = 12
        n /= 6
        Console.WriteLine("Division " & n)


   End Sub
End class

Add two integers together

Module Tester

   Sub Main()
      Dim firstNumber, secondNumber As String

      Dim number1, number2, sumOfNumbers As Integer

      firstNumber = 10

      secondNumber = 20

      number1 = firstNumber
      number2 = secondNumber

      sumOfNumbers = number1 + number2 ' add numbers
      Console.WriteLine("The sum is {0}", sumOfNumbers)

   End Sub ' Main

End Module

Define Integer variable and assign value

Module Module1
    Sub Main( )
       Dim myInt As Integer = 7
       Console.WriteLine("Initialized myInt: {0}", myInt)
       myInt = 5
       Console.WriteLine("After assignment myInt: {0}", myInt)
    End Sub
 End Module

Integer Family MaxValue

Public Class Tester
    Public Shared Sub Main
        Dim result As New System.Text.StringBuilder()
        result.AppendLine("MaxValue...")

        Dim maxByte As Byte = Byte.MaxValue
        Dim maxSByte As SByte = SByte.MaxValue
        Dim maxShort As Short = Short.MaxValue
        Dim maxUShort As UShort = UShort.MaxValue
        Dim maxInteger As Integer = Integer.MaxValue
        Dim maxUInteger As UInteger = UInteger.MaxValue
        Dim maxLong As Long = Long.MaxValue
        Dim maxULong As ULong = ULong.MaxValue

        result.Append("Byte ").AppendLine(maxByte)
        result.Append("SByte ").AppendLine(maxSByte)
        result.Append("Short ").AppendLine(maxShort)
        result.Append("UShort = ").AppendLine(maxUShort)
        result.Append("Integer = ").AppendLine(maxInteger)
        result.Append("UInteger = ").AppendLine(maxUInteger)
        result.Append("Long = ").AppendLine(maxLong)
        result.Append("ULong = ").AppendLine(maxULong)

        Console.WriteLine(result.ToString())
     End Sub
End Class

Explain the different parts that constitute ASP.NET application.

Content, program logic and configuration file constitute an ASP.NET application. Content files Content files include static text, images ...