Hi Friends,
I Can’t get StarBASIC Macro Result in the Two Scenario
- For Next Loop1
- For Next Loop2
But, I can get results in VBA Both Scenario. Here are the Code Sample VBA First and Calc_StarBASIC Codes. Can you help me the mistake, which i done ?
VBA Codes
For Next Loop1
Sub For_Next_Loop1()
Dim i As Long
Dim dt As Date
dt = "3/10/2023" ' yesterDay's Date
For i = 1 To 30
Range("A" & i).Value = dt + i
Next i
End Sub
Result
For Next Loop2
==============
Sub For_Next_Loop2()
Dim i As Long
For i = 1 To 30
Range("A" & i).Value = Date + i
Next i
End Sub
Result
Here, are the STAR BASIC codes
For Next Loop1
Dim Doc As Object, Sheets As Object, Sheet As Object
Sub For_Next_Loop1
Dim i As Long
Dim dt As Date
Doc = ThisComponent : Sheets = Doc.Sheets(0)
dt = ("3/10/2023") ' yesterDay's Date
For i = 1 To 30
Sheets.getCellRangeByName("A" & i).Formula = "= dt + i"
Next i
End Sub
Result
For Next Loop2
Sub For_Next_Loop2
Dim i As Long
Doc = ThisComponent : Sheets = Doc.Sheets(1)
For i = 1 To 30
Sheets.getCellRangeByName("A" & i).Formula = "=Date + i" ' Cell A1 To A30
Next i
End Sub