Sub FillItems(Sel as String, ObjToFill As Object)
If ObjToFill Is Spinner Then
Dim obj As Spinner
obj = ObjToFill
Else If ObjToFill Is ListView Then
Dim obj As ListView
obj = ObjToFill
End If
... code ...
End Sub
I'm getting the error msg "Current declaration does not match previous one" occuring at the
B4X:
Dim obj As ListView
line.
Does B4A not allow this sort of thing or is there a proper way of doing this?
I understand what you say but it doesn't fix the problem I'm afraid.
I am using the same variable so my code is shorter. ie instead of something like this:-
B4X:
If ObjToFill Is Spinner Then
Dim spn As Spinner = ObjToFill
... code manipulating object ...
Else If ObjToFill Is ListView Then
Dim lst as ListView = ObjToFill
... code manipulating object ...
End If
I wanted to do this:-
B4X:
If ObjToFill Is Spinner Then
Dim obj As Spinner
Else If ObjToFill Is ListView Then
Dim obj As ListView
End If
... code manipulating object
Ie Rather than having the manipulating code included a number of time (with all the issues with changes etc) I want it only include it once.
Any chance, in the future, this might be possible? My thinking comes from the way arrays are handled. If an array is dim'd again it just replaces the old array with the new one (as I understand it). The same is true for some functions, like messing with strings which just replace the old string with a new one.