Just kidding.
This has nothing to do with your problem except it's about VB.
I like going to VB boards and picking problems that are interesting and at or a little above my level. It's a good way to learn. I finished this in a few hours last night. I wrote it to demonstrate how you could take the amount off a check and convert it to writing to fill in the part you're supposed to write. It's buggy and only goes to 1000. Also everything is in one procedure. The arrays should be in a module and the rest should have be a sub routine(?).
(Beats crossword puzzles)
Private Sub cmdConvert_Click()
Const strCNote As String = "Hundred "
Const strDot As String = "."
Dim strLength As Integer
Dim intDotPos
Dim strLeftDigits As String
Dim intNumber As Integer
Dim intTens As Integer
Dim intSingles As Integer
Dim intHunds As Integer
Dim intCents As String
'Declare local arrays
Static Under20(19) As String
Static TensColumn(9) As String
'Load arrays
Under20(1) = "One "
Under20(2) = "Two "
Under20(3) = "Three "
Under20(4) = "Four "
Under20(5) = "Five "
Under20(6) = "Six "
Under20(7) = "Seven "
Under20(8) = "Eight "
Under20(9) = "Nine "
Under20(10) = "Ten "
Under20(11) = "Eleven "
Under20(12) = "Twelve "
Under20(13) = "Thirteen "
Under20(14) = "Fourteen "
Under20(15) = "Fifteen "
Under20(16) = "Sixteen "
Under20(17) = "Seventeen "
Under20(18) = "Eighteen "
Under20(19) = "Nineteen "
TensColumn(2) = "Twenty "
TensColumn(3) = "Thirty "
TensColumn(4) = "Forty "
TensColumn(5) = "Fifty "
TensColumn(6) = "Sixty"
TensColumn(7) = "Seventy "
TensColumn(8) = "Eighty "
TensColumn(9) = "Ninety "
'Decimal position
intDotPos = InStr(1, txtNumber, strDot)
'Return cents
intCents = Mid(txtNumber, (intDotPos + 1), 2)
'Check for decimal point
'If intDotPos = 0 Then
' strLeftDigits = Mid(txtNumber, 1)
'Else
'strLeftDigits = Mid(txtNumber, 1, (intDotPos - 1))
'End If
intNumber = Val(strLeftDigits)
If intNumber < 1 Then
txtOutput.Text = "." & intCents & " Cents"
End If
If intNumber < 20 Then
txtOutput.Text = Under20(intNumber) & "and " & intCents & "/100 Dollars"
End If
If intNumber >= 20 And intNumber < 100 Then
intTens = Mid(txtNumber, 1, 1)
intSingles = Mid(txtNumber, 2, 1)
txtOutput.Text = TensColumn(intTens) & Under20(intSingles) & "and " & _
intCents & "/100 Dollars"
End If
If intNumber >= 100 And intNumber < 1000 Then
intHunds = Mid(txtNumber, 1, 1)
intTens = Mid(txtNumber, 2, 1)
intSingles = Mid(txtNumber, 3, 1)
txtOutput.Text = Under20(intHunds) & strCNote & TensColumn(intTens) & _
Under20(intSingles) & "and " & intCents & "/100 Dollars"
End If
End Sub
PS
SM, Don't let anyone else see this...ok?
;-)
Geek Speak » in reply to re: You wish!
Fine, be that way.
