Wish Dim if a for next loop

JakeBullet70

Well-Known Member
Licensed User
Longtime User
Hi all

right now we do:

B4X:
Dim s as String = "Its a string" '--- love how we can do this

Dim x As Int
For x = 0 To 100
Next

can we get
B4X:
For x as Int = 0 To 100
Next

or is there a way to do this and I am missing it?
 

stevel05

Expert
Licensed User
Longtime User
You only need to do

B4X:
For x = 0 to 100
Next

No need to dim it first. It will be done automatically.
 

JakeBullet70

Well-Known Member
Licensed User
Longtime User
This is true. I am just so use to Dim'ing everything.

I wonder if there is a performance hit at all if you do not Dim it?
 

tzfpg

Active Member
Licensed User
Longtime User
how about using exit for? i add "exit for" return back error message.
B4X:
For k = 0 To Buffer.Length - 1
If int_hex>25 Then
full_hex(int_hex)=msg
Else
int_hex=0
Exit For
End If
Next

error message:

Parsing code. Error
Error parsing program.
Error description: Missing Keyword: next
Occurred on line: 88
End If
 
Cookies are required to use this site. You must accept them to continue using the site. Learn more…