lynsey2
Registered User.
- Local time
- Today, 11:15
- Joined
- Jun 18, 2002
- Messages
- 439
i am reciving a message Method or Data Member not found!
and i dont know why? i have code that conversts a number into words e.g. 2 = two
Here is that:
Function GetNumberText(nmbr)
Dim nmbr_format As String
Dim nmbr_text As String
Dim thousands, hundreds, tens, units As Integer
Dim and_required As Boolean
Dim digits_array As Variant
digits_array = Array("?", "one", "two", "three", "four", "five", "six", "seven", "eight", "nine")
Dim tens_array As Variant
tens_array = Array("?", "?", "twenty", "thirty", "forty", "fifty", "sixty", "seventy", "eighty", "ninety")
Dim teens_array As Variant
teens_array = Array("ten", "eleven", "twelve", "thirteen", "fourteen", "fifteen", "sixteen", "seventeen", "eighteen", "nineteen")
' check number within range
If ((nmbr < 1) Or (nmbr > 9999)) Then
GetNumberText = "Error - Number out of range."
Exit Function
End If
' initialise variables
nmbr_text = ""
nmbr_format = ""
' format number with leading zeros and get various parts
nmbr_format = Format(nmbr, "0000")
thousands = CInt(Mid(nmbr_format, 1, 1))
hundreds = CInt(Mid(nmbr_format, 2, 1))
tens = CInt(Mid(nmbr_format, 3, 1))
units = CInt(Mid(nmbr_format, 4, 1))
' suss out if and required before building string
If (((thousands > 0) Or (hundreds > 0)) And ((tens > 0) Or (units > 0))) Then
and_required = True
Else
and_required = False
End If
' thousands
If thousands > 0 Then nmbr_text = nmbr_text & digits_array(thousands) & " thousand "
' hundreds
If hundreds > 0 Then nmbr_text = nmbr_text & digits_array(hundreds) & " hundred "
' and
If and_required Then nmbr_text = nmbr_text & "and "
' tens/units - note if tens = 1 then use teens list (and don't bother with units)
If tens = 1 Then
nmbr_text = nmbr_text & teens_array(units)
Else
If tens > 0 Then nmbr_text = nmbr_text & tens_array(tens) & " "
If units > 0 Then nmbr_text = nmbr_text & digits_array(units)
End If
' this is the text version of the number
GetNumberText = Trim(nmbr_text)
End Function
i have a form with 2 text boxes on it
one of them that you enter the number e.g. 2 and i want the other to automatically come up with the word two...i really dont want to have a button to do this! i made a button though to check that that would work and i get that error mesage?
in the code for the button i put
Private Sub Command122_Click()
NumberofDosesTxT.Value = GetNumberText(numberofdoses.Value)
End Sub
any clues would be great as i am stuck...i made a totaly different form to try this and it seems to work with that so i take it i am missing something somewhere!
and i dont know why? i have code that conversts a number into words e.g. 2 = two
Here is that:
Function GetNumberText(nmbr)
Dim nmbr_format As String
Dim nmbr_text As String
Dim thousands, hundreds, tens, units As Integer
Dim and_required As Boolean
Dim digits_array As Variant
digits_array = Array("?", "one", "two", "three", "four", "five", "six", "seven", "eight", "nine")
Dim tens_array As Variant
tens_array = Array("?", "?", "twenty", "thirty", "forty", "fifty", "sixty", "seventy", "eighty", "ninety")
Dim teens_array As Variant
teens_array = Array("ten", "eleven", "twelve", "thirteen", "fourteen", "fifteen", "sixteen", "seventeen", "eighteen", "nineteen")
' check number within range
If ((nmbr < 1) Or (nmbr > 9999)) Then
GetNumberText = "Error - Number out of range."
Exit Function
End If
' initialise variables
nmbr_text = ""
nmbr_format = ""
' format number with leading zeros and get various parts
nmbr_format = Format(nmbr, "0000")
thousands = CInt(Mid(nmbr_format, 1, 1))
hundreds = CInt(Mid(nmbr_format, 2, 1))
tens = CInt(Mid(nmbr_format, 3, 1))
units = CInt(Mid(nmbr_format, 4, 1))
' suss out if and required before building string
If (((thousands > 0) Or (hundreds > 0)) And ((tens > 0) Or (units > 0))) Then
and_required = True
Else
and_required = False
End If
' thousands
If thousands > 0 Then nmbr_text = nmbr_text & digits_array(thousands) & " thousand "
' hundreds
If hundreds > 0 Then nmbr_text = nmbr_text & digits_array(hundreds) & " hundred "
' and
If and_required Then nmbr_text = nmbr_text & "and "
' tens/units - note if tens = 1 then use teens list (and don't bother with units)
If tens = 1 Then
nmbr_text = nmbr_text & teens_array(units)
Else
If tens > 0 Then nmbr_text = nmbr_text & tens_array(tens) & " "
If units > 0 Then nmbr_text = nmbr_text & digits_array(units)
End If
' this is the text version of the number
GetNumberText = Trim(nmbr_text)
End Function
i have a form with 2 text boxes on it
one of them that you enter the number e.g. 2 and i want the other to automatically come up with the word two...i really dont want to have a button to do this! i made a button though to check that that would work and i get that error mesage?
in the code for the button i put
Private Sub Command122_Click()
NumberofDosesTxT.Value = GetNumberText(numberofdoses.Value)
End Sub
any clues would be great as i am stuck...i made a totaly different form to try this and it seems to work with that so i take it i am missing something somewhere!