Develop a Component for Currency Conversion Using Com/.Net

Develop a Component for Currency Conversion Using Com/.Net

DEVELOP A COMPONENT FOR CURRENCY CONVERSION USING COM/.NET

AIM: To Create an component for currency conversion using com/.net

DESCRIPTION:

PART –1

CREATE A COMPONENT
  1. Start the process
  2. open VS .NET
  3. File-> New-> Project-> visual Basic Project -> class library, rename the class Library if required
  4. include the following coding in the class Library

Public Class Class1

Public Function dtor(ByVal rup As Double) As Double

Dim res As Double

res = rup * 47

Return (res)

End Function

Public Function etor(ByVal rup As Double) As Double

Dim res As Double

res = rup * 52

Return (res)

End Function

Public Function rtod(ByVal rup As Double) As Double

Dim res As Double

res = rup / 47

Return (res)

End Function

Public Function rtoe(ByVal rup As Double) As Double

Dim res As Double

res = rup / 52

Return (res)

End Function

End Class

  1. Build->Build the solution

Note: Register the dll using regsvr32 tool or copy the dll to c:\windows\system32.

Part –II

REFERENCING THE COMPONENT

1. Start the process

2. open VS .NET

  1. File-> New-> Project-> visual Basic Project -> Windows Application, rename the Windows Application if required
  2. Project -> Add Reference choose the com tab->Browse the dollartorupees.dll and click ok
  3. drag and drop the following controls in the form
  4. 2 Label Boxes
  5. 1 Text box
  6. 4 Buttons
  7. Include the coding in each of the Respective Button click Event.

Imports conversion2

Public Class Form1

Inherits System.Windows.Forms.Form

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

Dim obj As New convclass

Dim ret As Double

ret = obj.dtor(CDbl(TextBox1.Text))

MsgBox("The Equivalent Rupees for the given dollar" + ret.ToString())

End Sub

Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click

Dim obj As New convclass

Dim ret As Double

ret = obj.etor(CDbl(TextBox1.Text))

MsgBox("The Equivalent Rupees for the given euro" + ret.ToString())

End Sub

Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click

Dim obj As New convclass

Dim ret As Double

ret = obj.rtod(CDbl(TextBox1.Text))

MsgBox("The Equivalent Dollar Amount for the given rupees" + ret.ToString())

End Sub

Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click

Dim obj As New convclass

Dim ret As Double

ret = obj.rtoe(CDbl(TextBox1.Text))

MsgBox("The Equivalent Euro Amount for the given rupees" + ret.ToString())

End Sub

End Class

  1. Execute the project.