Re: [2005] better codeing
Quote:
Originally Posted by ikaris69
not sure what to call this so sorry for the title
ok say i have 10 variables
var1
var2
var3
var4
var5
var6
var7
var8
var9
var10
ok each of them needs to be processed into sql
so
VB Code:
'im just gonna write sql statement to much to write connection and everything
sql = "insert into table (jason) values (" & var1 & ")"
sql.execute
sql = "insert into table (jason) values (" & var2 & ")"
sql.execute
sql = "insert into table (jason) values (" & var3 & ")"
sql.execute
sql = "insert into table (jason) values (" & var4 & ")"
sql.execute
sql = "insert into table (jason) values (" & var5 & ")"
sql.execute
.......
.........
..........so on and so on
in my actual project it is much more complicated but thats the jist of it
now is there an easier way of doing this?
like doing a for loop 10 times or something. if i did a look i dont know how to change the var name to be based of the loop tho.
anyways thanks for your help in advance.
-JLR
dim var(9) as integer
just create an array.
Re: [2005] better codeing
Well if you are asking about the looping ...
You could try storing the information in an array and uses a loop for the Array.
e.g
Code:
dim array as new arraylist
array[0]=var1
array[1]=var2
.
.
.
for temp as integer =0 to 10
sql = "insert into table (jason) values (" & array[temp] & ")"
sql.execute
next
Re: [2005] better codeing
thanks for the replies
well i already do that with most of the information, but some reason i had coded(about 3 months ago) a certain few like the example and i could have sworn i saw a way to coding a loop around variables that were like that.
Re: [2005] better codeing
There was one in VB6, but I never used it. I remember people in that forum were often asking how could I call by a string name of a variable, and I believe there was a way. I don't remember what the technique was, just that it was fairly obscure, and I never had a use for it. You might try searching in that forum, but don't get your hopes up, it might well be something that didin't move over to .NET.
Re: [2005] better codeing
yeah thats what i remember thanks ill search for it