I am new to vba7 on ms word 2010 on w8-32 bit.
I am trying to pass an integer var arrIndexMax to a subroutine. The subroutine reads from a file and stores in an array, so this arrIndexMax var is supposed to hold the maximum value of the index of the array so that I can later restrict array execution to this value. I want arrIndexMax to get modified to the last read value index by the subroutine, so I am passing it byref.
When I am passing like this, (relevant code is boldened)
Dim arrMaatraasCode
arrMaatraasCode = Array(2366, 2367, 2368, 2369, 2370, 2371, 2372, 2375, 2376, 2377, 2379, 2380, 2307, 2381)
Dim arrMaatraas(13) As String
strMaatraasAll = " "
For arrIndex = 0 To UBound(arrMaatraasCode)
arrMaatraas(arrIndex) = ChrW(arrMaatraasCode(arrIndex))
strMaatraasAll = strMaatraasAll & arrMaatraas(arrIndex) & " "
Next arrIndex
'four unused letters stored to separate actual letters that get combined, these are a of four languages
strFiller = ChrW(2437) & ChrW(2565) & ChrW(2693) & ChrW(2821)
Dim arrInCode(512) As Integer
Dim arrFromChar(512) As String
Dim arrToChar(512) As String
**arrIndexMax = -1**
ReadConversionTable arrInCode, arrFromChar, arrToChar, strMaatraasAll, strFiller, **arrIndexMax**
then there is other code.
and, the called subroutine declaration later on is
Sub ReadConversionTable(arrInCode() As Integer, arrFromChar() As String, arrToChar() As String, ByVal strMaatraasAll As String, ByVal strFiller As String, **ByRef arrIndexMax As Integer**)
--
however, it just gives "Type mismatch", or byref error, or other kinds of errors at the same place, for various values.
changing Integer to Long in called subroutine also doesn't help.
Whereas all sites are saying that this is correct method.
When I try to define arrIndexMax As Integer, it doesn't allow.
What I am missing?