Datatypes project (see PowerPoint datatypes)

 

Public Class frmDataTypes

    Inherits System.Windows.Forms.Form

 

    'Note these examples use the default setting for

    'Option Strict as off

 

Private Sub btnSysDate_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSysDate.Click

        txtSysDate.Text = Now()

    End Sub

 

    Private Sub btnToday_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnToday.Click

        txtToday.Text = Today()

    End Sub

 

    Private Sub btnNewYear_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnNewYear.Click

        txtNewYear.Text = #1/1/2005#

    End Sub

 

    Private Sub btnVal_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnVal.Click

        'Correct way

        txtVal.Text = Val("123") * 2

        'Relying on implicit conversion

        txtValImplicit.Text = "123" * 2

    End Sub

 

    Private Sub btnToString_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnToString.Click

        Dim wkVariable As Integer = 123

        txtToString.Text = "The number is " & wkVariable

    End Sub

 

    Private Sub btnInteger_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnInteger.Click

        Dim wkInteger As Integer

        wkInteger = 123.45

        txtInteger.Text = wkInteger

    End Sub

 

    Private Sub btnDecimal_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnDecimal.Click

        Dim wkDecimal As Decimal

        wkDecimal = 123.45

        txtDecimal.Text = wkDecimal

    End Sub

End Class

 

Calculations project (see PowerPoint datatypes)

 

Public Class frmCalculations

    Inherits System.Windows.Forms.Form

Private Sub btnPower_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnPower.Click

        Dim wkNum As Integer = 5

        txtPower2.Text = wkNum ^ 2

        txtPower3.text = wkNum ^ 3

    End Sub

 

    Private Sub btnDivide_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnDivide.Click

        Dim wkToDivide As Decimal

        wkToDivide = 234.56

        txtDivide.Text = wkToDivide / 2

    End Sub

 

    Private Sub btnIntegerDivide_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnIntegerDivide.Click

        Dim wkIntDivide As Decimal

        wkIntDivide = 234.56

        txtIntegerDivide.Text = wkIntDivide \ 2

    End Sub

 

    Private Sub btnMod_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnMod.Click

        Dim wkMod As Integer, wkMod1 As Decimal

        wkMod = 20

        txtMod.Text = wkMod Mod 7

        wkMod1 = 20.45

        txtMod1.Text = wkMod1 Mod 7

    End Sub

End Class

 

OrderOperations Project (see PowerPoint datatypes)

 

Public Class frmOper

    Inherits System.Windows.Forms.Form

 

Private Sub btnFirst_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnFirst.Click

        Dim aa As Integer = 2

        Dim bb As Integer = 6

        Dim cc As Integer = 4

        Dim dd As Integer = 2

        Dim ee As Integer = 3

        lblFirst.Text = "a + b - c / d + e      or      2 + 6 - 4 / 2 + 3"

        txtFirst.Text = Val(aa + bb - cc / dd + ee)

    End Sub

 

    Private Sub btnSecond_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSecond.Click

        Dim aa As Integer = 2

        Dim bb As Integer = 6

        Dim cc As Integer = 4

        Dim dd As Integer = 2

        Dim ee As Integer = 3

        lblSecond.Text = "(a + b - c) / (d + e)      or      (2 + 6 - 4) / (2 + 3)"

        txtSecond.Text = Val((aa + bb - cc) / (dd + ee))

    End Sub

 

    Private Sub btnThird_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnThird.Click

        Dim aa As Integer = 10

        Dim bb As Integer = 3

        Dim cc As Integer = 4

        Dim dd As Integer = 500

        Dim ee As Integer = 2

        lblThird.Text = "(aa^bb * cc - dd) / ee     or     (10^3 * 4 - 500) / 2"

        txtThird.Text = (aa ^ bb * cc - dd) / ee

    End Sub

End Class

 

Convert Project (see PowerPoint datatypes)

 

Public Class frmConvert

    Inherits System.Windows.Forms.Form

 

Private Sub btnCBool_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCBool.Click

        Dim wkNum0 As Integer = 0

        Dim wkNum1 As Integer = 1

        txtBool0.Text = CBool(wkNum0)

        txtBool1.Text = CBool(wkNum1)

    End Sub

 

   

    Private Sub btnCBoolean_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCBoolean.Click

        Dim wkRslt As Boolean

        Dim wkFirst As Integer = 100

        Dim wkSecond As Integer = 200

        wkRslt = (wkFirst = wkSecond)

        txtBool.text = wkRslt

    End Sub

 

    Private Sub btnCDate_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCDate.Click

        Dim wkDatetoConvert As String = "December 12, 2004"

        Dim wkDate As Date

        wkDate = CDate(wkDatetoConvert)

        txtDate.text = wkDate

    End Sub

 

    Private Sub btnCDec_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCDec.Click

        Dim wkDollar As String = "$15,567.89"

        Dim wkDec As Decimal

        wkDec = CDec(wkDollar)

        txtCDec.Text = wkDec

    End Sub

 

    Private Sub btnCInt_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCInt.Click

        txtCInt.Text = CInt(378.287)

        txtCInt1.Text = CInt(378.787)

    End Sub

 

    Private Sub btnCStr_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCStr.Click

        Dim wkSq As Integer = 6 ^ 2

        txtCStr.Text = CStr(wkSq) & " is the square of " & CStr(6)

    End Sub

End Class

 

Formatting Project (see PowerPoint datatypes)

 

Public Class frmFormat

    Inherits System.Windows.Forms.Form

 

Private Sub frmFormatNumber_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles frmFormatNumber.Click

        Dim wkNum As Decimal = 123456.789

        txtFN.Text = FormatNumber(wkNum, 3)

    End Sub

 

    Private Sub btnFormatCurrency_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnFormatCurrency.Click

        Dim wkCurr As Decimal = 123456.789

        txtFC.Text = FormatCurrency(wkCurr)

    End Sub

 

    Private Sub btnFormatPercent_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnFormatPercent.Click

        Dim wkNum As Decimal = 12.34

        txtFP.Text = FormatPercent(wkNum, 1)

    End Sub

 

    Private Sub btnFormatPercent2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnFormatPercent2.Click

        Dim wkNum As Decimal = 0.1234

        txtFP2.Text = FormatPercent(wkNum)

    End Sub

 

    Private Sub btnFOrmatDateTime_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnFOrmatDateTime.Click

        Dim wkDate = "#10/15/2004#"

        txtFDT.Text = FormatDateTime(wkDate, DateFormat.LongDate)

    End Sub

End Class

 

AppwithLoad Project (see PowerPoint datatypes)

 

Public Class frmAppLoad

    Inherits System.Windows.Forms.Form

 

Private Sub frmAppLoad_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

        lblDate.Text = Today()

        txtCostCr.Text = FormatCurrency(100)

    End Sub

 

    Private Sub btnCalc_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCalc.Click

        Dim wkTotal As Decimal

        wkTotal = Val(txtNumCrs.Text) * CDec(txtCostCr.Text)

        txtTotal.Text = FormatCurrency(wkTotal)

    End Sub

 

    Private Sub btnClear_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnClear.Click

        txtName.Clear()

        txtStAdr.Clear()

        txtCSZ.Clear()

        txtNumCrs.Clear()

        txtTotal.Clear()

    End Sub

 

    Private Sub btnExit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnExit.Click

        End

    End Sub

End Class