VB Error: Array Names are Ambiguous - What Now?

  • Thread starter Thread starter zanazzi78
  • Start date Start date
  • Tags Tags
    Array Error
Click For Summary
The discussion revolves around a programming issue related to Visual Basic (VB) where the user encounters an "ambiguous name detected" error when defining an array. The user has defined an array as spd(n,n) but is unsure why VB is flagging it as ambiguous. Key points include the importance of explicitly defining all variables when using 'Option Explicit', which requires that every variable has a specified type. It is suggested that the user needs to declare 'n' as an integer using 'Dim n as integer' to avoid ambiguity. Additionally, it's noted that arrays can only be dimensioned with fixed values or constants, and if dynamic sizing is needed, the 'ReDim' function should be considered. The error may also arise if there are other variables, functions, or subs with the same name as the array being defined.
zanazzi78
Messages
115
Reaction score
1
To those who helped yesterday,again, thanks.

I have managed to resolve most of my problems, however, i have a new issue.

VB seemsto think that the names of my arrays are "ambiguous", WHY?

what do i need to do to resolve this new and fustrating problem?
 
Technology news on Phys.org
Can you elaborate?
 
In the optionexplict i`ve defined my array as spd(n,n)

Vb doesn`t like this and i don`t know why!
 
zanazzi78 said:
In the optionexplict i`ve defined my array as spd(n,n)
Vb doesn`t like this and i don`t know why!
Have you defined n?

'Option Explicit' means you must explictly define every variable with a type. If you merely say a(n,n) that's not explicit.

You first need 'Dim n as integer'.
 
Typically you can only dimension an array to either values (i.e. 4) or constants. If you have n defined as dim n as integer, it will (in my experience) kick the variable out. If you need to have it change size look at the redim function. Hope this helps
 
An "ambiguous name detected" error is caused by a sub, function, or some other variable or array having the same name as the one you are currently trying to define.
 
Learn If you want to write code for Python Machine learning, AI Statistics/data analysis Scientific research Web application servers Some microcontrollers JavaScript/Node JS/TypeScript Web sites Web application servers C# Games (Unity) Consumer applications (Windows) Business applications C++ Games (Unreal Engine) Operating systems, device drivers Microcontrollers/embedded systems Consumer applications (Linux) Some more tips: Do not learn C++ (or any other dialect of C) as a...

Similar threads

  • · Replies 2 ·
Replies
2
Views
2K
Replies
7
Views
1K
  • · Replies 17 ·
Replies
17
Views
3K
  • · Replies 23 ·
Replies
23
Views
2K
  • · Replies 28 ·
Replies
28
Views
3K
  • · Replies 4 ·
Replies
4
Views
3K
  • · Replies 2 ·
Replies
2
Views
2K
  • · Replies 11 ·
Replies
11
Views
12K
  • · Replies 6 ·
Replies
6
Views
3K
  • · Replies 31 ·
2
Replies
31
Views
3K