一向毌捌佇LibreOffice頂懸寫程式,為著欲寫點名表予全校導師用,加上政府今年開始推動ODF交換格式,用一寡時間揣相關資料來試看覓。下跤是簡單的記錄,嘛算是複習basic這个語言。伊是阮60年代出世老歲仔拄學電腦的時,逐家攏愛學的啦!是1960毌是民國60年代。想袂到進入軟體自由時代,這老硞硞的語言猶活ka遮好。
REM ***** BASIC *****
dim grade as long '年
dim mclass as long '班
dim Dlg as object
dim docu as object
dim dispatch as object
Sub Main
docu = ThisComponent.CurrentController.Frame
dispatch = createUnoService("com.sun.star.frame.DispatchHelper")
grade = 0
mclass = 0
DialogLibraries.LoadLibrary("Standard")
Dlg = CreateUnoDialog(DialogLibraries.Standard.createNameTable)
Dlg.Execute()
end sub
function sure()
if grade = 0 or mclass = 0 then
msgbox "愛添數字入去喔!"
else
call start(grade, mclass)
end if
end function
function setGrade()
grade = Dlg.getControl("grade").Value
end function
function setMclass()
mclass = Dlg.getControl("mclass").Value
end function
function start( grade as long, mclass as long)
dim sheet as object
dim range as new com.sun.star.table.CellRangeAddress
range.Sheet = 2
range.StartColumn = 1
range.StartRow = 1
range.EndColumn = 1
range.EndRow = 38
dim celladdr as new com.sun.star.table.CellAddress
celladdr.sheet = 0
celladdr.column = 1
celladdr.row = 5
dim count as long
dim srcsheet as object
dim recorded as boolean
srcsheet = ThisComponent.Sheets(2)
recorded = False
count = 0
for row=2 to 1610
myclass = srcsheet.getCellByPosition(3,row).getValue() '3是班級欄
mygrade = srcsheet.getCellByPosition(2,row).getValue()
if (myclass = mclass) and (mygrade = grade) then '2是年級欄
if not recorded then
range.StartRow = row
recorded = True
else count = count + 1
end if
end if
next
range.EndRow = range.StartRow + count
sheet = ThisComponent.Sheets(0)
sheet.getCellByPosition(4,0).setValue(grade)
sheet.getCellByPosition(7,0).setValue(mclass) '因為合𢍒併格位
sheet.copyRange(celladdr, range)
sheet = ThisComponent.Sheets(1)
celladdr.Sheet = 1 '1是背面
sheet.getCellByPosition(4,0).setValue(grade)
sheet.getCellByPosition(7,0).setValue(mclass)
sheet.copyRange(celladdr, range)
'有執行巨集,關學生名條
ThisComponent.Sheets(2).IsVisible = False
End function
沒有留言:
張貼留言