?
Solved

convert date to words in vb 6.0

Posted on 2006-05-12
3
Medium Priority
?
254 Views
Last Modified: 2008-01-09
i want to convert date to words in VB
Ex:
        13/05/2006
  Thirteen May Two Thousand Six
Can anyone help me.
0
Comment
Question by:vijayrajan_n
1 Comment
 
LVL 1

Accepted Solution

by:
rbvoigt earned 500 total points
ID: 16672647
Does this suit your purpose?


Public Function BeautifyNumber(ByVal n As Integer)
    Dim thousands As Integer
    thousands = Fix(n / 1000)
    Dim hundreds As Integer
    hundreds = Fix(n / 100)
    If thousands > 1 Or hundreds = 10 Then
        n = n Mod 1000
        BeautifyNumber = BeautifyNumber(thousands) & " Thousand" & IIf(n > 0, " " & BeautifyNumber(n), "")
        Exit Function
    End If
    If hundreds > 0 Then
        n = n Mod 100
        BeautifyNumber = BeautifyNumber(hundreds) & " Hundred" & IIf(n > 0, " " & BeautifyNumber(n), "")
        Exit Function
    End If
    Dim tens As Integer
    tens = Fix(n / 10)
    If tens > 1 Then
        n = n Mod 10
        BeautifyNumber = Choose(tens - 1, "Twenty", "Thirty", "Forty", "Fifty", "Sixty", "Seventy", "Eighty", "Ninety") & IIf(n > 0, "-" & BeautifyNumber(n), "")
        Exit Function
    End If
    If tens = 1 Then
        BeautifyNumber = Choose(n - 9, "Ten", "Eleven", "Twelve", "Thirteen", "Fourteen", "Fifteen", "Sixteen", "Seventeen", "Eighteen", "Nineteen")
    Else
        BeautifyNumber = Choose(n + 1, "Zero", "One", "Two", "Three", "Four", "Five", "Six", "Seven", "Eight", "Nine")
    End If
End Function

Function BeautifyDate(ByVal dy As Integer, ByVal mn As Integer, ByVal yr As Integer) As String
    BeautifyDate = BeautifyNumber(dy) & " " & MonthName(mn) & " " & BeautifyNumber(yr)
End Function
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Today, the web development industry is booming, and many people consider it to be their vocation. The question you may be asking yourself is – how do I become a web developer?
Q&A with Course Creator, Mark Lassoff, on the importance of HTML5 in the career of a modern-day developer.
Simple Linear Regression
Screencast - Getting to Know the Pipeline

840 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question