kgmmurugesh
Imports vb = Microsoft.VisualBasic
Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Me.Click
Dim yourNumber As Double = 123456789.12
Me.Text = Rupeeformat(yourNumber, "##,##,##,###.##")
End Sub
Public Function Rupeeformat(ByVal pAmount As Object, Optional ByVal Style As String = "") As String
Dim lctr As Integer
Dim lamount As String
Dim ReturnValue As String
Dim loci As Integer
Dim lstyle1 As String
Dim lstyle2 As String
loci = CShort(InStr(Style, "."))
If loci > 0 Then
lstyle1 = vb.Left$(Style, loci - 1)
lstyle2 = vb.Right$(Style, Len(Style) - loci)
Else
lstyle1 = Style
lstyle2 = Nothing
End If
lamount = Trim$(CStr(pAmount))
loci = CShort(InStr(CStr(lamount), "."))
lamount = Trim$(CStr(vb.Left$(CStr(lamount), loci - 1)))
lctr = CShort(Len(lamount))
For Loc_I = CShort(Len(lstyle1)) To 1 Step -1
If Mid$(Style, Loc_I, 1) = "#" Or Mid$(Style, Loc_I, 1) = "@" Then
ReturnValue = Mid$(lamount, lctr, 1) + ReturnValue
lctr = lctr - 1
Else
ReturnValue = Mid$(lstyle1, Loc_I, 1) + ReturnValue
End If
If lctr = 0 Then
Exit For
End If
Next
lamount = Trim$(CStr(pAmount))
lamount = Trim$(CStr(vb.Right$(CStr(lamount), Len(Trim$(CStr(lamount))) - loci)))
lctr = Len(lamount)
If lctr > 0 Then
ReturnValue = ReturnValue & "."
End If
For lctr = 1 To CShort(Len(lstyle2))
If Mid$(Style, lctr, 1) = "#" Or Mid$(Style, lctr, 1) = "@" Then
ReturnValue = ReturnValue + Mid$(lamount, lctr, 1)
Else
ReturnValue = ReturnValue + Mid$(lstyle2, lctr, 1)
End If
If lctr = 0 Then
Exit For
End If
Next
Rupeeformat = ReturnValue
End Function
End Class