用数组,
Ary1(1)="xm"
Ary2(1)="姓名"
Ary1(2)="km1"
Ary2(2)="科目1"
...
Ary1(n)="kmn"
Ary2(n)="科目n"
for i=1 to n
thisform.grid1.columns[i].header1.Caption= Ary2(i)
thisform.grid1.columns[i].ControlSource =Ary1(i)
Ary1(1)="xm"
Ary2(1)="姓名"
Ary1(2)="km1"
Ary2(2)="科目1"
...
Ary1(n)="kmn"
Ary2(n)="科目n"
for i=1 to n
thisform.grid1.columns[i].header1.Caption= Ary2(i)
thisform.grid1.columns[i].ControlSource =Ary1(i)