Probably you are trying to use a variable which you did not define yet (or trying to use a local variable to a function which has become inaccessible outside of its function).
Dim count As Integer = 42
Dim sub1(count) As String
Dim sub2(unknown) As String
Your naming is ambiguous, though. You may as well want to define a function, but functions are not defined with
Dim
keyword:
Public Function sub1(ByVal variable As Integer) As String
End Function