Compilation Error....Expected Array (1 Viewer)

Ashfaque

Student
Local time
Today, 05:41
Joined
Sep 6, 2004
Messages
894
Code:
Public Function ToArabicLetter(ByVal givenNumber As Double) As String
        Dim FinalOutput, Number, NumberMainCurrency, Fractions, FractionsMainCurrency As String
        Dim Only, WholeNumber As String
        Only = " áÇ ÛíÑ "

        WholeNumber = Split(givenNumber, ".")

        NumberMainCurrency = NumberAsMainCurrency(WholeNumber(0))
        FinalOutput = NumberMainCurrency

        If WholeNumber.Length >= 2 Then
            If WholeNumber(1).Length.Equals(1) Then
                WholeNumber(1) = WholeNumber(1) + "0"
            ElseIf WholeNumber(1).Length > 2 Then
                WholeNumber(1) = WholeNumber(1).Substring(0, 2)
            End If

            FractionsMainCurrency = FractionAsMainCurrency(WholeNumber(1))
            FinalOutput = FinalOutput + " ?" + FractionsMainCurrency
        End If

            If FinalOutput <> Nothing And FinalOutput <> "" Then
                FinalOutput = FinalOutput + Only
            End If

            ToArabicLetter = FinalOutput
    End Function
Hi,

After correction done at many place in whole code lines one of the function still produces an compilation error.
Attached function is giving requirement of an Expected Array...

NumberMainCurrency = NumberAsMainCurrency(WholeNumber(0))

Can someone help me please...
 

The_Doc_Man

Immoderate Moderator
Staff member
Local time
Yesterday, 19:11
Joined
Feb 28, 2001
Messages
27,147
Code:
Dim FinalOutput, Number, NumberMainCurrency, Fractions, FractionsMainCurrency As String

Well, for starters that syntax only declares one string. All the other items are declared as Variant type. The syntax you used works in some languages but doesn't work in VBA. You have to declare the type of EVERY variable in a DIM statement unlike FORTRAN (among others) that allow a single data type with a list of variables of that type.

You need that to read (in part):

Code:
Dim FinalOutput As String, Number As String, NumberMainCurrency As String, ....

By the way, NUMBER is a reserved word in Access and thus is not a good choice for a variable name. VBA can become "difficult" when it gets confused like that. And NUMBER is reserved because it is a keyword in DDL (part of SQL), so it doesn't pay to use it in a context where SQL is likely to be used.

Then there is the fact that you don't show us a definition of NumberAsMainCurrency so there is no telling what it wants to see. But I suspect that is a TYPO of NumberMainCurrency, in which case it doesn't know what that variable is, but the syntax is that of an array.
 

Ashfaque

Student
Local time
Today, 05:41
Joined
Sep 6, 2004
Messages
894
Thanks The_Doc_Man,

You are correct. I am converting some vb lines to VBA. Basically there are plenty of vb lines that executes successfully for to convert numbers to Arabic text. This error line is one of the functions from the full code.

I almost corrected all the code from vb to VBA but somewhere like this I am stuck. I want that all converted vb lines to work for my number to text conversion issue....

But even after changing to
Dim FinalOutput As String, Number As String, NumberMainCurrency As String, Fractions As String, FractionsMainCurrency As String

it producing same error.
 

Gasman

Enthusiastic Amateur
Local time
Today, 01:11
Joined
Sep 21, 2011
Messages
14,238
So show NumberAsMainCurrency() :(
 

Users who are viewing this thread

Top Bottom