+ Reply to Thread
Results 1 to 3 of 3

Money conversion code question...

  1. #1
    Registered User
    Join Date
    02-17-2015
    Location
    Turkey
    MS-Off Ver
    2010
    Posts
    3

    Money conversion code question...

    Hello All,

    I am quite bad at writing VBA codes but quite good at finding something already done and changing it to fit what I want to do.

    I converted below code from Turkish to convert numbers to verbal statments that write for example:

    SAY #ONEHUNDREDTWENTYTHOUSANDFOURHUNDREDTHIRTYTWOUSD# ONLY

    However, in Turkish for example, twelve is a combination of number ten and two; and it is written like that as well like tentwo. So, my code below returns interesting things for values below 20K like:

    SAY #TENONETHOUSANDNINEHUNDREDTENEIGHTUSDFORTYCENTS# ONLY (notice TENONE )

    I need help with this, how can I add numbers from eleven to nineteen in this code (and I just realized the code is in Turkish as well, I hope someone can help me)?

    Function USD(sayi)
    x = InStr(1, sayi, ",")
    If x > 0 Then
    Lira = "SAY #" & yaz$(Mid(sayi, 1, x - 1)) & "USD"
    TempKurus = Mid(sayi, x + 1, 98)
    If Len(TempKurus) = 1 Then TempKurus = TempKurus * 10
    If Len(TempKurus) > 2 Then TempKurus = Mid(TempKurus, 1, 2)
    Kurus = yaz$(TempKurus) & "CENTS# ONLY"
    Else
    Lira = "SAY #" & yaz$(sayi) & "USD# ONLY"
    End If
    USD = Lira & Kurus
    End Function

    Function yaz$(sayi)
    Dim b$(9)
    Dim y$(9)
    Dim m$(4)
    Dim v$(15)
    Dim c$(3)
    b$(0) = ""
    b$(1) = "ONE"
    b$(2) = "TWO"
    b$(3) = "THREE"
    b$(4) = "FOUR"
    b$(5) = "FIVE"
    b$(6) = "SIX"
    b$(7) = "SEVEN"
    b$(8) = "EIGHT"
    b$(9) = "NINE"
    y$(0) = ""
    y$(1) = "TEN"
    y$(2) = "TWENTY"
    y$(3) = "THIRTY"
    y$(4) = "FORTY"
    y$(5) = "FIFTY"
    y$(6) = "SIXTY"
    y$(7) = "SEVENTY"
    y$(8) = "EIGHTY"
    y$(9) = "NINETY"
    m$(0) = "TRILLION"
    m$(1) = "BILLION"
    m$(2) = "MILLION"
    m$(3) = "THOUSAND"
    m$(4) = ""
    a$ = Str(sayi)
    If Left$(a$, 1) = "" Then pozitif = 1 Else pozitif = 0
    a$ = Right$(a$, Len(a$) - 1)
    For x = 1 To Len(a$)
    If (Asc(Mid$(a$, x, 1)) > Asc("9")) Or (Asc(Mid$(a$, x, 1)) < Asc("0")) Then GoTo hata
    Next x
    If Len(a$) > 15 Then GoTo hata
    a$ = String(15 - Len(a$), "0") + a$
    For x = 1 To 15
    v(x) = Val(Mid$(a$, x, 1))
    Next x
    a$ = ""
    For x = 0 To 4
    c(1) = v((x * 3) + 1)
    c(2) = v((x * 3) + 2)
    c(3) = v((x * 3) + 3)
    If c(1) = 0 Then
    e$ = ""
    ElseIf c(1) = 1 Then
    e$ = "ONEHUNDRED"
    Else
    e$ = b$(c(1)) + "HUNDRED"
    End If
    e$ = e$ + y$(c(2)) + b$(c(3))
    If e$ <> "" Then e$ = e$ + m$(x)
    If (x = 3) And (e$ = "ONETHOUSAND") Then e$ = "THOUSAND"
    s$ = s$ + e$
    Next x
    If s$ = "" Then s$ = "ZERO"
    If pozitif = 0 Then s$ = "" + s$
    yaz$ = s$
    GoTo tamam
    hata: yaz$ = "hata"
    tamam:
    End Function

  2. #2
    Valued Forum Contributor
    Join Date
    08-29-2012
    Location
    In lockdown
    MS-Off Ver
    Excel 2010 (2003 to 2016 but 2010 for choice)
    Posts
    1,766

    Re: Money conversion code question...

    These threads may be of interest

    http://www.excelforum.com/excel-prog...nto-words.html

    http://www.excelforum.com/excel-prog...-currency.html

    http://www.excelforum.com/excel-prog...s-to-text.html

    Try adapting one of these to Turkish Currency. If you get stuck, let me know and I will have a look at where you're up to. HTH
    *******************************************************

    HELP WANTED! (Links to Forum threads)
    Trying to create reusable code for Custom Events at Workbook (not Application) level

    *******************************************************

  3. #3
    Valued Forum Contributor
    Join Date
    08-29-2012
    Location
    In lockdown
    MS-Off Ver
    Excel 2010 (2003 to 2016 but 2010 for choice)
    Posts
    1,766

    Re: Money conversion code question...

    Good to know it helped. Thanks for the rep.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Conversion Question
    By SupplyMan in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 10-01-2011, 10:59 PM
  2. Time Value of Money Question
    By jchoi2np in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 01-13-2009, 05:25 PM
  3. Conversion question
    By Tal72 in forum Excel General
    Replies: 4
    Last Post: 03-27-2008, 09:38 AM
  4. Replies: 2
    Last Post: 09-19-2007, 07:00 AM
  5. [SOLVED] conversion question
    By Tammi P in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 05-23-2006, 10:30 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1