任何主体都可以帮助将此代码从VB6转换为JavaScript 吗
Sub Insert()
Dim j As Long, r As Range
j = InputBox("Enter the number of sizes -1")
Set r = Range("A2")
Do
Range(r.Offset(1, 0), r.Offset(j, 0)).EntireRow.Insert
Set r = Cells(r.Row + j + 1, 1)
If r.Offset(1, 0) = "" Then Exit Do
Loop
End Sub
我不知道VB中的Range
或Cell
类,但如果您在JavaScript中重新实现它们的行为,您的代码可以转换为以下
function VBRange(/* args */) {
// re-implementation
}
function VBCells(/* args */) {
// re-implementation
}
function Insert() {
var j, r;
j = parseInt(prompt(Enter the number of sizes -1), 10);
r = VBRange("A2");
do {
VBRange(r.Offset(1, 0), r.Offset(j, 0)).EntireRow().Insert();
r = VBCells(r.Row + j + 1, 1);
if (r.Offset(1, 0) === "") {
break;
}
} while (1);
}