margret Well-Known Member Licensed User Longtime User Oct 29, 2012 #1 I have an If block as listed below in the Globals sub of the Main Activity. I need to Dim vv based on the SDK being used. This code throws an error and will not run. Can we not use an IF statement in Globals? Code: Copy If ph1.SdkVersion >= 14 Then Dim vv As VideoViewExt Else Dim vv As VideoView End If Compiling code. Error Error compiling program. Error description: Current declaration does not match previous one. Previous: {Type=VideoView,Rank=0} Current: {Type=VideoViewExt,Rank=0} Occurred on line: 74 Dim vv As VideoViewExt Click to expand... This is the first instance in the code to Dim vv. I have cleaned the project, etc. B4A seems to ignore the If condition and tries to Dim both vv's.
I have an If block as listed below in the Globals sub of the Main Activity. I need to Dim vv based on the SDK being used. This code throws an error and will not run. Can we not use an IF statement in Globals? Code: Copy If ph1.SdkVersion >= 14 Then Dim vv As VideoViewExt Else Dim vv As VideoView End If Compiling code. Error Error compiling program. Error description: Current declaration does not match previous one. Previous: {Type=VideoView,Rank=0} Current: {Type=VideoViewExt,Rank=0} Occurred on line: 74 Dim vv As VideoViewExt Click to expand... This is the first instance in the code to Dim vv. I have cleaned the project, etc. B4A seems to ignore the If condition and tries to Dim both vv's.
Erel B4X founder Staff member Licensed User Longtime User Oct 30, 2012 #2 The compiler must know the actual type of each variable during compilation. You will need to declare two variables and then to use the correct one based on the SdkVersion. Upvote 0
The compiler must know the actual type of each variable during compilation. You will need to declare two variables and then to use the correct one based on the SdkVersion.
margret Well-Known Member Licensed User Longtime User Oct 30, 2012 #3 OK, got it and that makes sense. BTW, B4A 2.22 is AWESOME! :sign0188: Upvote 0