I am getting this warning re vCellArray in next to last line of function
Public Function ExtractCells(ByRef OrigFormula As String) As Object(,)
Dim vCellArray(,) As Object
'Irrelevant Code deleted
ValidCellCount = ValidCellCount + 1
ReDim Preserve vCellArray(3, ValidCellCount)
vCellArray(0, 0) = ValidCellCount
vCellArray(1, ValidCellCount) = tempStr
vCellArray(2, ValidCellCount) = PossibleStartPosition
vCellArray(3, ValidCellCount) = PossibleEndingPosition
End If
ValidCell = False
Next 'Candidate
End If
If ValidCellCount = 0 Then
ReDim Preserve vCellArray(3, ValidCellCount + 1)
vCellArray(0, 0) = 0
End If
ExtractCells = vCellArray
Return ExtractCells
End Function
As far as I know, The warning lets you know that there is no Array object associated with the variable, if you run it you will get an exception as there is no Array object so it can't assign a value to an element.
So, please debug your code step by step to find which code causes the warning. You could also share us more relevant code to help us reproduce the problem.
Best Regards,
Yohann Lu
ASP.NET forums are moving to a new home on Microsoft Q&A, we encourage you to go to Microsoft Q&A for .NET for posting new questions and get involved today. Learn more >
Member
105 Points
533 Posts
How to eliminate warning: array used before being assigned a value
Oct 03, 2016 01:27 PM|sg48asp|LINK
I am getting this warning re vCellArray in next to last line of function
Star
11464 Points
2439 Posts
Re: How to eliminate warning: array used before being assigned a value
Oct 04, 2016 06:52 AM|Yohann Lu|LINK
Hi sg48asp,
As far as I know, The warning lets you know that there is no Array object associated with the variable, if you run it you will get an exception as there is no Array object so it can't assign a value to an element.
So, please debug your code step by step to find which code causes the warning. You could also share us more relevant code to help us reproduce the problem.
Best Regards,
Yohann Lu
All-Star
52813 Points
15768 Posts
Re: How to eliminate warning: array used before being assigned a value
Oct 04, 2016 07:10 AM|oned_gk|LINK
Try this
Suwandi - Non Graduate Programmer
Member
105 Points
533 Posts
Re: How to eliminate warning: array used before being assigned a value
Oct 04, 2016 10:53 AM|sg48asp|LINK
If I run it, there is no error. This is just a warning at before running.
Member
105 Points
533 Posts
Re: How to eliminate warning: array used before being assigned a value
Oct 04, 2016 11:01 AM|sg48asp|LINK
Thanks-That worked.
I also tried Dim vCellArray(3,100) which also worked. It gets redimensioned later.