hi all....i have a string which accepts money...in any form like...123456 or 1,23,456.00 or 3456.00...... finally i want it to be coverted to...1,23,456.0 0, 3,456.00 (comma after lakhs,thousands ....with a double digit precision)....p lease tell me if there is any fucntion or a code to accomplish this ASAP....
Function to convert money value to pure indian type
Collapse
X
-
-
hey thks for reply...i know format function helps in tht case..but its returning the value as....123,456.0 0..if the input is more than 1lakh......also i used formatnumber... enen then the result is same....i want it to return...as...1 ,23,456.00..... ..reply me ASAP....thks for any kind of help...
Originally posted by debasisdasyou need to use the FORMAT function for the purpose.Comment
-
try like this
Format(12345678 .00004, "###,###,###.## ###")
AND DO NOT START A DUPLICATE THREAD FOR THE SAME QUESTIONComment
-
Hi,
I Guess, using any Combination of Locale setting and Format, you would end up with a Digit grouping of 3 Digits..
You can write a Format function of your own..
Try this :
[code=vb]
Private Function MyFormat(ByVal TNum As String) As String
'
Dim TStr As String
Dim OStr As String
Dim TempStr As String
'
TNum = Replace(TNum, ",", "")
'
OStr = Format(TNum, "0.00")
TStr = Right(OStr, 6)
If Len(OStr) <= 6 Then
MyFormat = TStr
Else
OStr = Left(OStr, Len(OStr) - 6)
Do
TempStr = Right(OStr, 2)
TStr = TempStr & "," & TStr
OStr = Left(OStr, Len(OStr) - Len(TempStr))
Loop Until Trim(OStr) = ""
MyFormat = TStr
End If
'
End Function
[/code]
To Call this Function, use this code:
[code=vb]
Private Sub Text1_LostFocus ()
Text1.Text = MyFormat(Text1)
End Sub
[/code]
Regards
VeenaComment
-
thks for the reply..but the result it generates is....12,345,67 8.00004......wi ch is not i wanted....plz it should seperate lakhs with a comma...thousan ds with a comma...and so on.....the output should be like....1,23,45 ,678.00......pl z help me out....
Originally posted by debasisdastry like this
Format(12345678 .00004, "###,###,###.## ###")
AND DO NOT START A DUPLICATE THREAD FOR THE SAME QUESTIONComment
-
-
Hi!
Here is the Code you are looking for. Please Find the attachment here with this post.
With Regards
Vijay. RAttached FilesComment
-
infact..i shud say thks to veena(QVeen72 )....tht code worked well...thks a lot..for ur help..
Originally posted by QVeen72Hi,
I Guess, using any Combination of Locale setting and Format, you would end up with a Digit grouping of 3 Digits..
You can write a Format function of your own..
Try this :
[code=vb]
Private Function MyFormat(ByVal TNum As String) As String
'
Dim TStr As String
Dim OStr As String
Dim TempStr As String
'
TNum = Replace(TNum, ",", "")
'
OStr = Format(TNum, "0.00")
TStr = Right(OStr, 6)
If Len(OStr) <= 6 Then
MyFormat = TStr
Else
OStr = Left(OStr, Len(OStr) - 6)
Do
TempStr = Right(OStr, 2)
TStr = TempStr & "," & TStr
OStr = Left(OStr, Len(OStr) - Len(TempStr))
Loop Until Trim(OStr) = ""
MyFormat = TStr
End If
'
End Function
[/code]
To Call this Function, use this code:
[code=vb]
Private Sub Text1_LostFocus ()
Text1.Text = MyFormat(Text1)
End Sub
[/code]
Regards
VeenaComment
Comment