Make Click event Object Oriented

Make Click event Object Oriented with a Class

Page 1 of 1

0 Replies - 1536 Views - Last Post: 27 November 2007 - 04:15 PM Rate Topic: -----

#1 libby50  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 15
  • Joined: 08-November 07

Make Click event Object Oriented

Post icon  Posted 27 November 2007 - 04:15 PM

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...

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



Is This A Good Question/Topic? 0
  • +

Page 1 of 1