473,387 Members | 1,553 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Function to convert money value to pure indian type

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.00, 3,456.00 (comma after lakhs,thousands....with a double digit precision)....please tell me if there is any fucntion or a code to accomplish this ASAP....
Jul 22 '08 #1
9 2331
debasisdas
8,127 Expert 4TB
you need to use the FORMAT function for the purpose.
Jul 23 '08 #2
hey thks for reply...i know format function helps in tht case..but its returning the value as....123,456.00..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...

you need to use the FORMAT function for the purpose.
Jul 23 '08 #3
debasisdas
8,127 Expert 4TB
try like this

Format(12345678.00004, "###,###,###.#####")


AND DO NOT START A DUPLICATE THREAD FOR THE SAME QUESTION
Jul 23 '08 #4
QVeen72
1,445 Expert 1GB
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 :

Expand|Select|Wrap|Line Numbers
  1. Private Function MyFormat(ByVal TNum As String) As String
  2.     '
  3.     Dim TStr As String
  4.     Dim OStr As String
  5.     Dim TempStr As String
  6.     '
  7.     TNum = Replace(TNum, ",", "")
  8.     '
  9.     OStr = Format(TNum, "0.00")
  10.     TStr = Right(OStr, 6)
  11.     If Len(OStr) <= 6 Then
  12.         MyFormat = TStr
  13.     Else
  14.         OStr = Left(OStr, Len(OStr) - 6)
  15.         Do
  16.             TempStr = Right(OStr, 2)
  17.             TStr = TempStr & "," & TStr
  18.             OStr = Left(OStr, Len(OStr) - Len(TempStr))
  19.         Loop Until Trim(OStr) = ""
  20.         MyFormat = TStr
  21.     End If
  22.     '
  23. End Function
  24.  
To Call this Function, use this code:
Expand|Select|Wrap|Line Numbers
  1. Private Sub Text1_LostFocus()
  2.     Text1.Text = MyFormat(Text1)
  3. End Sub
  4.  
Regards
Veena
Jul 23 '08 #5
thks for the reply..but the result it generates is....12,345,678.00004......wich is not i wanted....plz it should seperate lakhs with a comma...thousands with a comma...and so on.....the output should be like....1,23,45,678.00......plz help me out....

try like this

Format(12345678.00004, "###,###,###.#####")


AND DO NOT START A DUPLICATE THREAD FOR THE SAME QUESTION
Jul 23 '08 #6
debasisdas
8,127 Expert 4TB
cant you change the position of comma ?
Jul 23 '08 #7
smartchap
236 100+
Code from QVeen works fine but after modifying for a negative number.
Jul 26 '08 #8
VijaySofist
107 100+
Hi!

Here is the Code you are looking for. Please Find the attachment here with this post.

With Regards
Vijay. R
Attached Files
File Type: txt RupeesToWords.txt (9.5 KB, 467 views)
Jul 26 '08 #9
infact..i shud say thks to veena(QVeen72 )....tht code worked well...thks a lot..for ur help..


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 :

Expand|Select|Wrap|Line Numbers
  1. Private Function MyFormat(ByVal TNum As String) As String
  2.     '
  3.     Dim TStr As String
  4.     Dim OStr As String
  5.     Dim TempStr As String
  6.     '
  7.     TNum = Replace(TNum, ",", "")
  8.     '
  9.     OStr = Format(TNum, "0.00")
  10.     TStr = Right(OStr, 6)
  11.     If Len(OStr) <= 6 Then
  12.         MyFormat = TStr
  13.     Else
  14.         OStr = Left(OStr, Len(OStr) - 6)
  15.         Do
  16.             TempStr = Right(OStr, 2)
  17.             TStr = TempStr & "," & TStr
  18.             OStr = Left(OStr, Len(OStr) - Len(TempStr))
  19.         Loop Until Trim(OStr) = ""
  20.         MyFormat = TStr
  21.     End If
  22.     '
  23. End Function
  24.  
To Call this Function, use this code:
Expand|Select|Wrap|Line Numbers
  1. Private Sub Text1_LostFocus()
  2.     Text1.Text = MyFormat(Text1)
  3. End Sub
  4.  
Regards
Veena
Aug 1 '08 #10

Sign in to post your reply or Sign up for a free account.

Similar topics

24
by: Batista, Facundo | last post by:
Here I send it. Suggestions and all kinds of recomendations are more than welcomed. If it all goes ok, it'll be a PEP when I finish writing the code. Thank you. .. Facundo
0
by: Bill | last post by:
I'm getting the following error: Disallowed implicit conversion from data type varchar to data type money, table 'bill.dbo.cart', column 'price'. Use the CONVERT function to run this query. ...
1
by: shank | last post by:
I'm getting the following error... Microsoft OLE DB Provider for SQL Server error '80040e07' Disallowed implicit conversion from data type varchar to data type money, table 'wsOrders', column...
3
by: teddysnips | last post by:
In the script below is the DDL to create some tables and a UDF. What I'm interested in is the UDF at the end. Specifically, these few lines: --CLOSE OTRate --DEALLOCATE OTRate ELSE --...
5
by: mike | last post by:
If I have a document like: <script> function mike_test() {alert('hi');} </script> <iframe src="blank.html" id="my_iframe1"> </iframe> and in blank.html I have:
4
by: mpurnachary | last post by:
Hi... Plz... Help me... I want some code for Converting a Number (money) to Words in Indian Format in C#.NET eg.: if I enter 12345678 then it gives as ... " ONE CRORE TWENTY...
10
by: SQACPP | last post by:
Hi, I try to figure out how to use Callback procedure in a C++ form project The following code *work* perfectly on a console project #include "Windows.h" BOOL CALLBACK...
53
by: souporpower | last post by:
Hello All I am trying to activate a link using Jquery. Here is my code; <html> <head> <script type="text/javascript" src="../../resources/js/ jquery-1.2.6.js"</script> <script...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.