BBS: Inland Empire Archive Date: 03-13-93 (02:11) Number: 384 From: TOM COAKLEY Refer#: NONE To: ALL Recvd: NO Subj: Number to a string Conf: (2) Quik_Bas

I saw an earlier post where someone requested some quick basic code that would convert a number (123.15) to a string (One Hundred Twenty Three 15/100) I pulled the following code from a one of my programs. ========================================================================SUBNUMWORD (NUM#, WORD$)DIMONEARRAY$(9)DIMNUMARRAY$(9)DIMTEENARRAY$(9) ONEARRAY$(1) = "One " ONEARRAY$(2) = "Two " ONEARRAY$(3) = "Three " ONEARRAY$(4) = "Four " ONEARRAY$(5) = "Five " ONEARRAY$(6) = "Six " ONEARRAY$(7) = "Seven " ONEARRAY$(8) = "Eight " ONEARRAY$(9) = "Nine " NUMARRAY$(1) = "TEEN LISTING" NUMARRAY$(2) = "Twenty " NUMARRAY$(3) = "Thirty " NUMARRAY$(4) = "Forty " NUMARRAY$(5) = "Fifty " NUMARRAY$(6) = "Sixty " NUMARRAY$(7) = "Seventy " NUMARRAY$(8) = "Eighty " NUMARRAY$(9) = "Ninety " TEENARRAY$(1) = "Eleven " TEENARRAY$(2) = "Twelve " TEENARRAY$(3) = "Thirteen " TEENARRAY$(4) = "Fourteen " TEENARRAY$(5) = "Fifteen " TEENARRAY$(6) = "Sixteen " TEENARRAY$(7) = "Seventeen " TEENARRAY$(8) = "Eighteen " TEENARRAY$(9) = "Nineteen " WORD$ = "" NUM$ = STR$(NUM#) NUM$ = RIGHT$(NUM$, LEN(NUM$) - 1) NUMLEN = LEN(NUM$) DECCHECK = INSTR(NUM$, ".")IFDECCHECK > 0THENDECIMAL$ = RIGHT$(NUM$, NUMLEN - DECCHECK)ENDIFDENOMINATOR$ = "10"FORZEROS = 1TOLEN(DECIMAL$) DENOMINATOR$ = DENOMINATOR$ + "0"NEXTZEROS DECIMAL$ = DECIMAL$ + "/" + DENOMINATOR$ NUM$ = LEFT$(NUM$, DECCHECK - 1) NUMLEN = LEN(NUM$)WHILENUMLEN > 0 NUM$ = RIGHT$(NUM$, NUMLEN) NUMCHECK$ = LEFT$(NUM$, 1) NUMCHECK = VAL(NUMCHECK$)ONNUMLENGOSUBONES, TENS, HUNDREDS, THOUSANDS, TENTHOUSANDS, HUNDREDTHOUSA NUMLEN = NUMLEN - 1 WEND WORD$ = WORD$ + DECIMAL$EXITSUBHUNDREDTHOUSANDS: WORD$ = WORD$ + ONEARRAY$(NUMCHECK) + "Hundred "RETURNTENTHOUSANDS:IFNUMCHECK$ = "1"THENGOSUBTEENS: WORD$ = WORD$ + "Thousand "ELSEWORD$ = WORD$ + NUMARRAY$(NUMCHECK)ENDIFRETURNTHOUSANDS: WORD$ = WORD$ + ONEARRAY$(NUMCHECK) + "Thousand "RETURNHUNDREDS: WORD$ = WORD$ + ONEARRAY$(NUMCHECK) + "Hundred "RETURNTENS:IFNUMCHECK$ = "1"THENGOSUBTEENS: WORD$ = WORD$ELSEWORD$ = WORD$ + NUMARRAY$(NUMCHECK)ENDIFRETURNONES: WORD$ = WORD$ + ONEARRAY$(NUMCHECK)RETURNTEENS: NUMLEN = NUMLEN = NUMLEN - 1 NUMCHECK$ = RIGHT$(NUM$, 1) NUMCHECK = VAL(NUMCHECK$) WORD$ = WORD$ + TEENARRAY$(NUMCHECK)RETURNENDSUB===================================================================== I hope this solves your problem. Tom --- þ SLMR 2.1a þ --- þ SLMR 2.1a þ --- FidoPCB v1.4 beta * Origin: ASA CompuHelp "We're A Step Ahead" (614)476-4058 (1:226/600)

Echo Basic Postings

**Books at Amazon:**

Back to BASIC: The History, Corruption, and Future of the Language

Hackers: Heroes of the Computer Revolution (including Tiny BASIC)

Go to: The Story of the Math Majors, Bridge Players, Engineers, Chess Wizards, Scientists and Iconoclasts who were the Hero Programmers of the Software Revolution

The Advent of the Algorithm: The Idea that Rules the World

Moths in the Machine: The Power and Perils of Programming

Mastering Visual Basic .NET