Welcome to Dream.In.Code
Become a VB.NET Expert!

Join 149,545 VB.NET Programmers for FREE! Get instant access to thousands of VB.NET experts, tutorials, code snippets, and more! There are 1,562 people online right now. Registration is fast and FREE... Join Now!




Make Click event Object Oriented

 
Reply to this topicStart new topic

Make Click event Object Oriented, Make Click event Object Oriented with a Class

libby50
27 Nov, 2007 - 03:15 PM
Post #1

New D.I.C Head
*

Joined: 8 Nov, 2007
Posts: 15


My Contributions
I need to make this click event object oriented using a class with 3 instances variables.. Here I have the code...just need help on putting everything together to make work properly...THANKS in advance...

CODE

ption Explicit On

Imports System.Globalization


Public Class MainForm
    'declare instance variables of Mainform
    Private myCurrent As Loan
    Private myRate As Loan
    Private myNper As Loan
    Private isConverted As Boolean


    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        'instantiate an objects
        myCurrent = New Loan()
        myRate = New Loan()
        MyNper = New Loan()
    End Sub

    Private Sub ExitButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ExitButton.Click
        Me.Close()
    End Sub


    Private Sub ResetButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ResetButton.Click
        principalTextBox.Clear()
        IntTextBox.Clear()
        TermTextBox.Clear()
    End Sub

    Private Sub CalcButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CalcButton.Click
        Dim Rate As Decimal
        Dim Nper As Double
        Dim PV As Double
        Dim CalculateTotal As Loan
        Dim value As Decimal
        Dim total As Decimal
        Dim Current As Double
        ' Setting the values to each of our variables.    
        Rate = value
        Nper = 4
        PV = value

        If isConverted Then
            'calculate total

            total = CalculateTotal()

            PaymentsLabel.Text = total

        End If



    End Sub

End Class
[/code


[code]
Public Class Loan
    'instance variables
    Private _current As Decimal
    Private _rate As Decimal
    Private _nper As Decimal
  
    ' constructor
    Public Sub New(Optional ByVal theCurrent As Decimal = 0, _
                   Optional ByVal theRate As Decimal = 0, _
                   Optional ByVal theNper As Decimal = 0)
        _current = theCurrent
        _rate = theRate
        _nper = theNper
    End Sub

    'Property procedures
    Public Property Current() As Decimal
        Get
            Return _current
        End Get
        Set(ByVal value As Decimal)
            _current = value
        End Set
    End Property


    'Property procedures
    Public Property Rate() As Decimal
        Get
            Return _rate
        End Get
        Set(ByVal value As Decimal)
            _rate = value
        End Set
    End Property


    'Property procedures
    Public Property Nper() As Decimal
        Get
            Return _nper
        End Get
        Set(ByVal value As Decimal)
            _nper = value
        End Set
    End Property


    Public Function CalculateTotal() As Decimal
        Return -Financial.Pmt(Rate, Nper, Current)
    End Function



End Class



User is offlineProfile CardPM
+Quote Post

Fast ReplyReply to this topicStart new topic
Time is now: 1/7/09 09:29PM

Be Social

Dream.In.Code RSS Feed Dream.In.Code LinkedIn Group Follow Us On Twitter

Live VB.NET Help!

VB.NET Tutorials

Reference Sheets

VB.NET Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month