Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 adding two variable names in VBScript

Author  Topic 

kev510
Starting Member

5 Posts

Posted - 2006-07-13 : 14:09:57
Hello everyone.

I am a newbie in VBScript, trying to add two variable names together (vColName and i), and then add a value to it at the same time.

"i" is a number dynamically changed by "for i = 0 to vColCnt", so that the result will become "vColName1", "vColName2", etc while "FOR NEXT" runs. I've already tried

vColCnt = objRecordset.fields.count

for i = 0 to vColCnt
vColName&i = objRecordset.fields(i).name
Next

but I get a syntax error. Please help! Thanks!!

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2006-07-13 : 15:27:54
[code]vColCnt = objRecordset.fields.count

vColName = ""
for i = 0 to vColCnt
IF i= 0 Then
vColName = objRecordset.fields(i).name
Else
vColName = vColName & ", " & objRecordset.fields(i).name
ENd if
Next[/code]


Peter Larsson
Helsingborg, Sweden
Go to Top of Page
   

- Advertisement -