hi everyone can someone please help am trying to convert numbers to words but there no response at all when i run the prog. i used the codes below

Function Getword(strNumber)
 Dim strtemp As String
 Dim x, y, z As Integer
 x = Val(Mid$(strNumber, 1, 1))
 y = Val(Mid$(strNumber, 2, 1))
 z = Val(Mid$(strNumber, 3, 1))
 If Len(strNumber) = 1 Then
 strtemp = strtemp + Whole(Val(strNumber))
 GoTo 20
 ElseIf Len(strNumber) = 2 Then
 If x = 1 And y = 0 Then
 strtemp = strtemp + " Ten"
 ElseIf x = 1 And y = 1 Then
 strtemp = strtemp + " Eleven"
 GoTo 20
 ElseIf x = 1 And y = 2 Then
 strtemp = strtemp + " Twelve"
 GoTo 20
 ElseIf x = 1 And y > 2 Then
 strtemp = strtemp + Whole2(y) + "een"
 GoTo 20
 ElseIf x = 0 And y > 0 Then
 strtemp = strtemp + Whole(y)
 GoTo 20
 ElseIf x = 0 And y = 0 Then
 strtemp = ""
 GoTo 20
 Else
 strtemp = Whole2(x) + "y"
 If y > 0 Then
 strtemp = strtemp + Whole(y)
 GoTo 20
 End If
 ElseIf Len(strNumber) = 3 Then
If x > 0 Then strtemp = strtemp + Whole(x) + " Hundred"
If y = 1 And z > 2 Then
strtemp = strtemp + Whole2(z) + "een"
GoTo 20
ElseIf y = 1 And z = 1 Then
strtemp = strtemp + " Eleven"
GoTo 20
ElseIf y = 1 And z = 2 Then
strtemp = strtemp + " Twelve"
GoTo 20
ElseIf y = 1 And z = 0 Then
strtemp = strtemp + " Ten"
GoTo 20
ElseIf x = 0 And y = 0 And z = 0 Then
strtemp = ""
GoTo 20
Else
End If
If y > 0 Then
strtemp = strtemp + Whole2(y) + "y"
If z > 0 Then
strtemp = strtemp + Whole(z)
End If
20 Getword = strtemp
End Function



Function Whole(ByVal x As Integer)
Select Case x
Case Is = 9
Whole = " Nine"
Case 8
Whole = " Eight"
Case 7
Whole = " Seven"
Case 6
Whole = " Six"
Case 5
Whole = " Five"
Case 4
Whole = " Four"
Case 3
Whole = " Three"
  Case 2
  Whole = " Two"
  Case 1
  Whole = " One"
  End Select
  End Function
  Function Whole2(ByVal x As Integer)
  Select Case x
  Case Is = 9
  Whole2 = " Ninet"
  Case 8
  Whole2 = " Eight"
  Case 7
  Whole2 = " Sevent"
  Case 6
  Whole2 = " Sixt"
  Case 5
  Whole2 = " Fift"
  Case 4
  Whole2 = " Fourt"
  Case 3
  Whole2 = " Thirt"
  Case 2
  Whole2 = " Twent"
  End Select
  End Function
  Private Sub Command1_Click()
  Dim bigstrNumber(11)
  Dim strAdd As String
  Dim strNumber As String
  Dim strtemp As String
  Txtone = Abs(Int(Txtone))
  strNumber = Txtone.Text
  Txttwo = ""
  bigstrNumber(0) = ""
  bigstrNumber(1) = " Thousand"
  bigstrNumber(2) = " Million"
  bigstrNumber(3) = " Billion"
  bigstrNumber(4) = " Trillion"
  bigstrNumber(5) = " Quadrillion"
  bigstrNumber(6) = " Pentillion"
  bigstrNumber(7) = " Hexillion"
  bigstrNumber(8) = " Qentillion"
  bigstrNumber(9) = " Octillion"
  bigstrNumber(10) = " Nonillion"
  bigstrNumber(11) = " Decillion"
  If Len(strNumber) > 3 Then
  Do While i < 36
  m = m + 1
  i = i + 3
 If i >= Len(strNumber) Then Exit Do
 Loop
 c = i - Len(strNumber)
 If c > 0 Then
 For D = 1 To c
 strAdd = strAdd + "0"
 Next D
 Else
 End If
 strNumber = strAdd + strNumber
 k = 1
 For i = 1 To m
 Txttwo = Txttwo & Getword(Mid$(strNumber, k, 3))
 If Mid$(strNumber, k, 3) <> "000" Then
 Txttwo = Txttwo & bigstrNumber(m - i)
 k = k + 3
 Next i
 Else
 End If
 Txttwo = Trim$(Txttwo & Getword(strNumber))
 Txtone = Format$(Txtone, "###,###,###,###,###,###,###,###,###,###,###,###")
 End Sub

courtesy Abu taher

Recommended Answers

All 3 Replies

properly change the textbox and button name as I said. look clearly. button name commandbutton1 and textbox name textbox1 and textbox2.

its very simple check out the attachment

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.