sql server 2008 R2数据库, VB6 循环不支持步长为负数?
VB6编写的程序,以前是写入access数据库,步长为负数的循环没有问题。今天把Access数据库转移到SQL server 2008 R2数据库,发现最后那个循环语句不执行:
Set xlApp = CreateObject("Excel.Application")
xlApp.Visible = False
Set xlBook = xlApp.Workbooks.Open("D:\temp\清单.xlsx")
Set xlsheet = xlBook.Worksheets(1)
xlsheet.Activate
For i = 107 To 120
xlsheet.Cells(7, i - 101) = Label5(i).Caption
xlsheet.Cells(8, i - 101) = Label5(i + 14).Caption
xlsheet.Cells(11, i - 101) = Label5(i - 59).Caption
Next i
xlsheet.Cells(11, 5) = Label5(48).Caption
For i = 62 To 76
xlsheet.Cells(14, i - 60) = Label5(i).Caption
xlsheet.Cells(15, i - 60) = Label5(i + 15).Caption
xlsheet.Cells(18, i - 60) = Label5(i + 30).Caption
Next i
For i = 191 To 177 - 1
xlsheet.Cells(16, i - 189) = Label5(i).Caption
xlsheet.Cells(17, i - 189) = Label5(i - 15).Caption
Next i
xlBook.RunAutoMacros (xlAutoOpen)
xlBook.ActiveSheet.PrintOut
xlBook.RunAutoMacros (xlAutoClose)
xlBook.Close
xlApp.Quit
Set xlApp = Nothing
为什么会出现这种情况?应该怎么处理?
[解决办法]
For i = 191 To 177 - 1
你这个叫负步长吗?循环根本就没有执行
lz要的是:
For i = 191 To 177 step - 1 吧?