Hi all!
What is the best code between to code bellow to insert data in DB
I have to dim many variables. I want to know if it's better to dim variables outside the for next loop and affecting variable inside for next like this
Or redim inside the for next like this
I just want to have the best coding practice
Note: the code is only to illustrade my idea.
What is the best code between to code bellow to insert data in DB
I have to dim many variables. I want to know if it's better to dim variables outside the for next loop and affecting variable inside for next like this
B4X:
dim name1 as string
dim name2 as int
dim name3 as double
dim sqlRequest as string
for x=0 to field.size-1
name1="blalba"
name2=112345
name3=1.12345
sqlRequest="insert into .... blabla
blabla
...
next
Or redim inside the for next like this
B4X:
for x=0 to field.size-1
dim name1 as string="blalba"
dim name2 as int=112345
dim name3 as double=1.12345
dim sqlRequest as string
sqlRequest="insert into .... blabla
blabla
...
next
I just want to have the best coding practice
Note: the code is only to illustrade my idea.