我有变量Student1, Student2, Student3 and Student
我在跑步时为Student1,Student2和Student3分配值。
在将这些值插入数据库之前,我将这些值分配给学生变量,然后将它们插入数据库,如:
For i = 1 to 3
InsertData = "Student" & i
Next
在这里,我无法传递Student1, Student2 and Student3 to Student
变量的值。我怎么能这样做?
提前致谢
CODE:
Student1 = "abc"
Student2 = "def"
Student3 = "ghi"
i = 0
For i = 1 To 3
Set httpReq = New MSXML2.xmlhttp
httpReq.Open "POST", InsertDataURL, False
httpReq.setRequestHeader "Content-Type", "application/x-www-form-urlencoded"
InsertData = "Student" & i
httpReq.send InsertData
InsertData = ""
Set httpReq = Nothing
Next i
答案 0 :(得分:0)
我认为您只需要在打开HTTP请求之前将变量赋值的位置移动到:
i = 0
For i = 1 To 3
Set httpReq = New MSXML2.xmlhttp
InsertData = "Student" & i
httpReq.Open "POST", InsertData, False
httpReq.setRequestHeader "Content-Type", "application/x-www-form-urlencoded"
httpReq.send PostData
PostData = ""
Set httpReq = Nothing
Next i