Terimakasih sebelumnya mbak,
sebetulnya saya sudah punya untuk Function terbilang Indonesia yang saya
letakkan di database SQL Server jadi bukan diaplikasi, ini sourcenya :
yang saya tidak punya adalah yang bhs inggrisnya.
CREATE FUNCTION dbo.F_TERBILANG(@NVAL NUMERIC(18,2))
RETURNS VARCHAR(1000)
AS
BEGIN
DECLARE
@aBIL VARCHAR(100),
@aBIL1 VARCHAR(100),
@cVAR1 VARCHAR(500),
@cVAR2 VARCHAR(500),
@cVAR3 VARCHAR(500),
@cVAR4 VARCHAR(500),
@HASIL VARCHAR(1000),
@KOMA VARCHAR(5),
@I INT,
@J INT,
@ANGKA BIGINT,
@P2 NUMERIC(30),
@ZB INT,
@ZB0 CHAR(3),
@ZB1 INT,
@ZB2 INT,
@ZB3 INT
SET @HASIL = ''
SET @aBIL='SATU DUA TIGA EMPAT LIMA ENAM TUJUH DELAPAN
SEMBILAN'
SET @aBIL1=' RIBU JUTA MILYARDTRILIUN '
IF @nVAL=0
SET @Hasil='NOL'
SET @Angka=CAST((@nVAL) AS BIGINT )
SET @Koma=LTRIM(SUBSTRING(STR(@nval,18,2),16,3))
SET @i=5
WHILE ( @ANGKA<>0 )
BEGIN
SET @cVAR1=''
SET @cVAR2=''
SET @cVAR3=''
SET @i = @i - 1
/* Buat P2 = 1000^i */
SET @J = 1
IF @i = 0
SET @P2 = 1
ELSE
BEGIN
SET @P2 = 1000
WHILE @J < @I
BEGIN
SET @P2 = @P2 * 1000
SET @J = @J + 1
END
END
SET @ZB=CAST((@Angka/@P2) AS INT )
IF @ZB=0
CONTINUE
SET @ZB0=STR(@ZB,3,0) /*ambil 3 angka dari awal */
SET @ZB1=CAST((SUBSTRING(@ZB0,1,1)) AS INT )
SET @ZB2=CAST((SUBSTRING(@ZB0,2,1)) AS INT )
SET @ZB3=CAST((SUBSTRING(@ZB0,3,1)) AS INT )
/* test ratusan */
IF @ZB1<>0
BEGIN
IF @ZB1=1
SET @cVAR1=' SERATUS '
ELSE
SET @cVAR1=' '+RTRIM(SUBSTRING(@aBIL,(@ZB1-1)*8+1,8))+' RATUS '
END
/* test puluhan & belasan */
IF @ZB2=1
BEGIN
IF @ZB3=0
SET @cVAR2=' SEPULUH '
ELSE
BEGIN
IF @ZB3=1
SET @cVAR2=' SEBELAS '
ELSE
SET @cVAR2=' '+RTRIM(SUBSTRING(@aBIL,(@ZB3-1)*8+1,8))+' BELAS '
END
END
ELSE
BEGIN
IF @ZB3<>0
SET @cVAR3=' '+RTRIM(SUBSTRING(@aBIL,(@ZB3-1)*8+1,8))
IF @ZB2<>0
SET @cVAR2=RTRIM(SUBSTRING(@aBIL,(@ZB2-1)*8+1,8))+' PULUH '
END
IF @i>0
SET @[EMAIL PROTECTED]@[EMAIL PROTECTED]@cVar3+'
'+RTRIM(SUBSTRING(@aBIL1,@i*7+1,7))
ELSE
SET @[EMAIL PROTECTED]@[EMAIL PROTECTED]@cVar3
SET @Angka = @Angka -(@[EMAIL PROTECTED])
END
-- End Loop ------------------
IF SUBSTRING(ltrim(@Hasil),1,9)='SATU RIBU'
SET @Hasil='SERIBU '+RTRIM(Right(@Hasil,LEN(LTRIM(@Hasil))-9))
ELSE
SET @Hasil=RTRIM(@Hasil)
SET @cVar4=' '
IF SUBSTRING(STR(@nVAL,18,2),16,1)='.' and right(@koma,2)<>'00'
BEGIN
SET @i = 1
WHILE @i <= 2
BEGIN
IF SUBSTRING(@KOMA,@i,1)='0'
SET @[EMAIL PROTECTED]'NOL '
else
SET @cVAR4=LTRIM(@cVar4)+'
'+RTRIM(SUBSTRING(@aBIL,(CAST(SUBSTRING(right(@koma,2),@i,1) AS INTEGER ) -
1)*8+1,8))
SET @i = @i + 1
END
END
IF @cVAR4<>' '
SET @HASIL = @HASIL+' KOMA '[EMAIL PROTECTED]
RETURN (LTRIM(@HASIL))
END
djayanti wagnah <[EMAIL PROTECTED]> wrote:
ini yach sourcenya :
Private Sub ConvertABN()
If IsNumeric(txtValueTransfer) Then
txtWord.Text = SpellNumber(CDbl(txtValueTransfer))
txtWord.SelStart = 0
txtWord.SelLength = Len(txtValueTransfer)
Else
Beep
End If
End Sub
Function SpellNumber(ByVal MyNumber)
Dim Dollars, Cents, Temp
Dim DecimalPlace, Count
ReDim Place(9) As String
Place(2) = " Thousand "
Place(3) = " Million "
Place(4) = " Billion "
Place(5) = " Trillion "
' String representation of amount.
MyNumber = Trim(Str(MyNumber))
' Position of decimal place 0 if none.
DecimalPlace = InStr(MyNumber, ".")
' Convert cents and set MyNumber to dollar amount.
If DecimalPlace > 0 Then
Cents = GetTens(Left(Mid(MyNumber, DecimalPlace + 1) & _
"00", 2))
MyNumber = Trim(Left(MyNumber, DecimalPlace - 1))
End If
Count = 1
Do While MyNumber <> ""
Temp = GetHundreds(Right(MyNumber, 3))
If Temp <> "" Then Dollars = Temp & Place(Count) & Dollars
If Len(MyNumber) > 3 Then
MyNumber = Left(MyNumber, Len(MyNumber) - 3)
Else
MyNumber = ""
End If
Count = Count + 1
Loop
Select Case Dollars
Case ""
Dollars = "" 'Dollars"
Case "One"
Dollars = " One USD"
Case Else
Dollars = Dollars & " USD"
End Select
Select Case Cents
Case ""
Cents = "" 'and No Cents"
Case "One"
Cents = " and One Cent"
Case Else
Cents = " and " & Cents & " Cents"
End Select
SpellNumber = Dollars & Cents
End Function
' Converts a number from 100-999 into text
Function GetHundreds(ByVal MyNumber)
Dim Result As String
If Val(MyNumber) = 0 Then Exit Function
MyNumber = Right("000" & MyNumber, 3)
' Convert the hundreds place.
If Mid(MyNumber, 1, 1) <> "0" Then
Result = GetDigit(Mid(MyNumber, 1, 1)) & " Hundred "
End If
' Convert the tens and ones place.
If Mid(MyNumber, 2, 1) <> "0" Then
Result = Result & GetTens(Mid(MyNumber, 2))
Else
Result = Result & GetDigit(Mid(MyNumber, 3))
End If
GetHundreds = Result
End Function
' Converts a number from 10 to 99 into text.
Function GetTens(TensText)
Dim Result As String
Result = "" ' Null out the temporary function value.
If Val(Left(TensText, 1)) = 1 Then ' If value between 10-19...
Select Case Val(TensText)
Case 10: Result = "Ten"
Case 11: Result = "Eleven"
Case 12: Result = "Twelve"
Case 13: Result = "Thirteen"
Case 14: Result = "Fourteen"
Case 15: Result = "Fifteen"
Case 16: Result = "Sixteen"
Case 17: Result = "Seventeen"
Case 18: Result = "Eighteen"
Case 19: Result = "Nineteen"
Case Else
End Select
Else ' If value between 20-99...
Select Case Val(Left(TensText, 1))
Case 2: Result = "Twenty "
Case 3: Result = "Thirty "
Case 4: Result = "Forty "
Case 5: Result = "Fifty "
Case 6: Result = "Sixty "
Case 7: Result = "Seventy "
Case 8: Result = "Eighty "
Case 9: Result = "Ninety "
Case Else
End Select
Result = Result & GetDigit _
(Right(TensText, 1)) ' Retrieve ones place.
End If
GetTens = Result
End Function
' Converts a number from 1 to 9 into text.
Function GetDigit(Digit)
Select Case Val(Digit)
Case 1: GetDigit = "One"
Case 2: GetDigit = "Two"
Case 3: GetDigit = "Three"
Case 4: GetDigit = "Four"
Case 5: GetDigit = "Five"
Case 6: GetDigit = "Six"
Case 7: GetDigit = "Seven"
Case 8: GetDigit = "Eight"
Case 9: GetDigit = "Nine"
Case Else: GetDigit = ""
End Select
End Function
----- Original Message ----
From: McBoenBoen <[EMAIL PROTECTED]>
To: [email protected]; [email protected]; Waroeng VB
<[EMAIL PROTECTED]>
Sent: Friday, March 16, 2007 10:01:21 AM
Subject: [indoprog-vb] Urgent : Terbilang Bhs Inggris
Dear All,
minta tolong dong source code terbilang dabahas inggris
urgent bangt nih..
thxx b4
mc
------------ --------- --------- ---
Food fight? Enjoy some healthy debate
in the Yahoo! Answers Food & Drink Q&A.
[Non-text portions of this message have been removed]
Send instant messages to your online friends http://uk.messenger.yahoo.com
[Non-text portions of this message have been removed]
---------------------------------
No need to miss a message. Get email on-the-go
with Yahoo! Mail for Mobile. Get started.
[Non-text portions of this message have been removed]