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
- Start the process
- open VS .NET
- File-> New-> Project-> visual Basic Project -> class library, rename the class Library if required
- 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
- 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
- File-> New-> Project-> visual Basic Project -> Windows Application, rename the Windows Application if required
- Project -> Add Reference choose the com tab->Browse the dollartorupees.dll and click ok
- drag and drop the following controls in the form
- 2 Label Boxes
- 1 Text box
- 4 Buttons
- 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
- Execute the project.