VB Error: Array Names are Ambiguous - What Now?

In summary, The speaker thanks those who helped yesterday and mentions having resolved most of their problems but now facing a new issue. They explain that their arrays are being deemed "ambiguous" and ask for a resolution. The person responding suggests checking if 'n' has been defined and explains that 'Option Explicit' requires explicit definition of variables. They also mention the 'Redim' function for changing array size. They conclude by stating that an "ambiguous name detected" error is caused by conflicting variable or array names.
  • #1
zanazzi78
115
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
  • #2
Can you elaborate?
 
  • #3
In the optionexplict i`ve defined my array as spd(n,n)

Vb doesn`t like this and i don`t know why!
 
  • #4
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'.
 
  • #5
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
 
  • #6
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.
 

Related to VB Error: Array Names are Ambiguous - What Now?

What does "Array Names are Ambiguous" mean in VB Error?

When you receive the error message "Array Names are Ambiguous" in VB, it means that there are multiple variables or arrays with the same name in your code. This can cause confusion for the program and result in errors.

How can I fix the "Array Names are Ambiguous" error?

To fix the "Array Names are Ambiguous" error, you will need to go through your code and make sure that each variable and array has a unique name. You can also use the "Option Explicit" statement at the beginning of your code to force yourself to declare all variables and avoid this error.

Why am I getting the "Array Names are Ambiguous" error?

The "Array Names are Ambiguous" error typically occurs when you have declared multiple variables or arrays with the same name, either in the same module or in different modules that are being used in your code. This can cause conflicts and confusion for the program.

Can I have multiple variables or arrays with the same name in VB?

No, you cannot have multiple variables or arrays with the same name in VB. This will result in the "Array Names are Ambiguous" error and can also cause unexpected behavior in your program. It is important to use unique names for each variable and array to avoid this issue.

Is there a way to prevent the "Array Names are Ambiguous" error from occurring?

Yes, you can prevent the "Array Names are Ambiguous" error by using unique names for each variable and array in your code. You can also use the "Option Explicit" statement to force yourself to declare all variables and avoid any conflicts. Additionally, it is a good practice to regularly review your code and ensure that all variable and array names are unique.

Similar threads

  • Programming and Computer Science
Replies
2
Views
1K
  • Programming and Computer Science
Replies
4
Views
510
  • Programming and Computer Science
Replies
2
Views
1K
  • Programming and Computer Science
Replies
23
Views
1K
  • Programming and Computer Science
Replies
17
Views
2K
  • Programming and Computer Science
Replies
31
Views
2K
  • Programming and Computer Science
Replies
6
Views
1K
  • Programming and Computer Science
Replies
5
Views
10K
  • Programming and Computer Science
Replies
28
Views
3K
  • Programming and Computer Science
Replies
5
Views
3K
Back
Top