Im learning programing logic with VBA and im trying to do a array, but i have a error in the running
Dim auxTexto As String
Dim auxNumero As Long
Dim auxIterador As Integer
Dim auxArrayEstatico(0 To 5) As Integer
Dim auxArrayDinamico As String
Sub prueba()
auxTexto = "Hola"
auxNumero = 1
auxArrayEstatico(0) = 2
auxArrayEstatico(1) = 2
auxArrayEstatico(2) = 2
auxArrayEstatico(3) = 2
auxArrayEstatico(4) = 2
MsgBox ("Valor de Array en posicion 3 es " & auxArrayEstatico(3))
ReDim auxArrayDinamico(0 To 3)
auxArrayDinamico(0) = "Hola"
MsgBox (auxArrayDinamico(0))
End Sub
The error say "Error of copilation, expected a array" Please, somebody can help me?
CodePudding user response:
removed "as string", also moved variables inside sub.
For faster debugging, try replacing msgbox "hola"...
with debug.print "hola"...
. this will just send the text to the immediate window for quick viewing.
Option Explicit
Sub prueba()
Dim auxTexto As String
Dim auxNumero As Long
Dim auxIterador As Integer
Dim auxArrayEstatico(0 To 5) As Integer
Dim auxArrayDinamico
auxTexto = "Hola"
auxNumero = 1
auxArrayEstatico(0) = 2
auxArrayEstatico(1) = 2
auxArrayEstatico(2) = 2
auxArrayEstatico(3) = 2
auxArrayEstatico(4) = 2
MsgBox ("Valor de Array en posicion 3 es " & auxArrayEstatico(3))
ReDim auxArrayDinamico(0 To 3)
auxArrayDinamico(0) = "Hola"
MsgBox (auxArrayDinamico(0))
End Sub