ເນື້ອໃນ

# ການໃຊ້ຟັງຊັນ Calc ໃນມາກໂຄ

ນອກຈາກຟັງຊັນພື້ນຖານຂອງ BASIC ແລ້ວ, ທ່ານຍັງສາມາດຮຽກໃຊ້ຟັງຊັນ Calc ໃນມາກໂຄ ແລະ ສະຄຣິບຂອງທ່ານໄດ້, ລວມທັງຕັ້ງຄ່າຟັງຊັນ Calc ໃນສູດຂອງເຊລ.

## ການຮຽກໃຊ້ຟັງຊັນພາຍໃນຂອງ Calc ໃນ Basic

ໃຊ້ຟັງຊັນ CreateUnoService ເພື່ອເຂົ້າເຖິງບໍລິການ com.sun.star.sheet.FunctionAccess.

### ຕົວຢ່າງ:

ຕົວຢ່າງດ້ານລຸ່ມຈະສ້າງຟັງຊັນຊື່ MyVlook ເຊິ່ງຮຽກໃຊ້ຟັງຊັນ VLOOKUP ຂອງ Calc ຜ່ານອາເຣຂໍ້ມູນທີ່ສົ່ງເປັນອາກິວເມັນ ແລະ ສົ່ງຄືນຄ່າທີ່ຟັງຊັນຄົ້ນພົບ.

        Function MyVlook(Lookup, DataArray As Object, Index As Integer, SortedRangeLookup as Byte)
            Dim oService As Object
            Set oService = CreateUnoService("com.sun.star.sheet.FunctionAccess")
            ' ໃຫ້ໃຊ້ຊື່ຟັງຊັນເປັນພາສາອັງກິດສະເໝີ
            MyVlook = oService.callFunction("VLOOKUP", Array(Lookup, DataArray, Index, SortedRangeLookup))
        End Function

ມາກໂຄດ້ານລຸ່ມສະແດງຕົວຢ່າງວິທີຮຽກໃຊ້ຟັງຊັນ MyVlook. ທຳອິດມັນຈະສ້າງອາເຣຂໍ້ມູນຂະໜາດ 5x2, ຈາກນັ້ນຮຽກໃຊ້ຟັງຊັນ MyVlook ແລະ ສະແດງຜົນຄ່າທີ່ສົ່ງຄືນມາດ້ວຍ MsgBox.

        Sub CallingMyVlook()
            ' ສ້າງອາເຣຂະໜາດ 5 x 2 ແລະ ປ້ອນຂໍ້ມູນໃສ່
            Dim myData(1 to 5, 1 to 2) as Variant
            myData(1, 1) = 1 : myData(1, 2) = "ບໍ່ເຫັນດີຢ່າງຍິ່ງ"
            myData(2, 1) = 3 : myData(2, 2) = "ບໍ່ເຫັນດີ"
            myData(3, 1) = 5 : myData(3, 2) = "ບໍ່ແນ່ໃຈ"
            myData(4, 1) = 7 : myData(4, 2) = "ເຫັນດີ"
            myData(5, 1) = 9 : myData(5, 2) = "ເຫັນດີຢ່າງຍິ່ງ"
            ' ຄົ້ນຫາຂໍ້ມູນໃນອາເຣ
            Dim result as String
            result = MyVlook(4, myData, 2, 1)
            ' ສະແດງຂໍ້ຄວາມ "ບໍ່ເຫັນດີ"
            MsgBox result
        End Sub

## ການຕັ້ງຄ່າສູດເຊລທີ່ປະກອບດ້ວຍຟັງຊັນພາຍໃນຂອງ Calc

ໃຊ້ຂໍ້ຄວາມສູດເພື່ອແຊກສູດໃສ່ໃນເຊລຂອງສະເປຣດຊີດ.

ຟັງຊັນ Calc ທັງໝົດຕ້ອງຖືກລະບຸດ້ວຍຊື່ພາສາອັງກິດ.

### ຕົວຢ່າງ:

    Sub AssignFormulaToCell
    REM ແຊກສູດໃສ່ເຊລ A1. ຊື່ຟັງຊັນຕ້ອງເປັນພາສາອັງກິດ.
        oCell = ThisComponent.Sheets.getByIndex(0).getCellRangeByName("A1")
        oCell.Formula = "=SUM(B1:B10)"
    REM ເຊລ A1 ຈະສະແດງຊື່ຟັງຊັນຕາມພາສາທ້ອງຖິ່ນ
    End Sub

## ການຮຽກໃຊ້ຟັງຊັນ Add-In ຂອງ Calc ໃນ BASIC

ຟັງຊັນ Add-In ຂອງ Calc ຢູ່ໃນບໍລິການ UNO com.sun.star.sheet.addin.Analysis, com.sun.star.sheet.addin.DateFunctions ແລະ com.sun.star.sheet.addin.PricingFunctions.

### ຕົວຢ່າງ:

    REM ຕົວຢ່າງການຮຽກໃຊ້ຟັງຊັນ Add-in SQRTPI
    Function MySQRTPI(arg as double) as double
       Dim oService as Object
       oService = CreateUnoService("com.sun.star.sheet.addin.Analysis")
       MySQRTPI = oService.getSqrtPi(arg)
    End Function

## ການຕັ້ງຄ່າສູດເຊລດ້ວຍຟັງຊັນ Add-In

ຟັງຊັນ Add-In ຕ້ອງຖືກລະບຸດ້ວຍຊື່ບໍລິການ UNO ຂອງມັນ.

### ຕົວຢ່າງ:

    Sub AssignAddInFormulaToCell
    REM ແຊກສູດ Add-In ໃສ່ເຊລ A1. ຊື່ຟັງຊັນແມ່ນຊື່ບໍລິການ UNO.
        oCell = ThisComponent.Sheets.getByIndex(0).getCellRangeByName("A1")
        oCell.Formula = "=com.sun.star.sheet.addin.Analysis.getBin2Dec(B1)"
    REM ເຊລ A1 ຈະສະແດງຊື່ຟັງຊັນຕາມພາສາທ້ອງຖິ່ນ
    End Sub

## ຊື່ບໍລິການ UNO ສຳລັບຟັງຊັນ Analysis Add-In

ຕາຕະລາງດ້ານລຸ່ມສະແດງລາຍການຟັງຊັນ Calc Analysis Add-In ທັງໝົດ ແລະ ຊື່ບໍລິການ UNO ທີ່ກົງກັນ.

ຊື່ຟັງຊັນ Calc | ຊື່ບໍລິການ UNO
--- | ---
ACCRINT | com.sun.star.sheet.addin.Analysis.getAccrint
ACCRINTM | com.sun.star.sheet.addin.Analysis.getAccrintm
AMORDEGRC | com.sun.star.sheet.addin.Analysis.getAmordegrc
AMORLINC | com.sun.star.sheet.addin.Analysis.getAmorlinc
BESSELI | com.sun.star.sheet.addin.Analysis.getBesseli
BESSELJ | com.sun.star.sheet.addin.Analysis.getBesselj
BESSELK | com.sun.star.sheet.addin.Analysis.getBesselk
BESSELY | com.sun.star.sheet.addin.Analysis.getBessely
BIN2DEC | com.sun.star.sheet.addin.Analysis.getBin2Dec
BIN2HEX | com.sun.star.sheet.addin.Analysis.getBin2Hex
BIN2OCT | com.sun.star.sheet.addin.Analysis.getBin2Oct
COMPLEX | com.sun.star.sheet.addin.Analysis.getComplex
CONVERT | com.sun.star.sheet.addin.Analysis.getConvert
COUPDAYBS | com.sun.star.sheet.addin.Analysis.getCoupdaybs
COUPDAYS | com.sun.star.sheet.addin.Analysis.getCoupdays
COUPDAYSNC | com.sun.star.sheet.addin.Analysis.getCoupdaysnc
COUPNCD | com.sun.star.sheet.addin.Analysis.getCoupncd
COUPNUM | com.sun.star.sheet.addin.Analysis.getCoupnum
COUPPCD | com.sun.star.sheet.addin.Analysis.getCouppcd
CUMIPMT | com.sun.star.sheet.addin.Analysis.getCumipmt
CUMPRINC | com.sun.star.sheet.addin.Analysis.getCumprinc
DEC2BIN | com.sun.star.sheet.addin.Analysis.getDec2Bin
DEC2HEX | com.sun.star.sheet.addin.Analysis.getDec2Hex
DEC2OCT | com.sun.star.sheet.addin.Analysis.getDec2Oct
DELTA | com.sun.star.sheet.addin.Analysis.getDelta
DISC | com.sun.star.sheet.addin.Analysis.getDisc
DOLLARDE | com.sun.star.sheet.addin.Analysis.getDollarde
DOLLARFR | com.sun.star.sheet.addin.Analysis.getDollarfr
DURATION | com.sun.star.sheet.addin.Analysis.getDuration
EDATE | com.sun.star.sheet.addin.Analysis.getEdate
EFFECT | com.sun.star.sheet.addin.Analysis.getEffect
EOMONTH | com.sun.star.sheet.addin.Analysis.getEomonth
ERF | com.sun.star.sheet.addin.Analysis.getErf
ERFC | com.sun.star.sheet.addin.Analysis.getErfc
FACTDOUBLE | com.sun.star.sheet.addin.Analysis.getFactdouble
FVSCHEDULE | com.sun.star.sheet.addin.Analysis.getFvschedule
GCD | com.sun.star.sheet.addin.Analysis.getGcd
GESTEP | com.sun.star.sheet.addin.Analysis.getGestep
HEX2BIN | com.sun.star.sheet.addin.Analysis.getHex2Bin
HEX2DEC | com.sun.star.sheet.addin.Analysis.getHex2Dec
HEX2OCT | com.sun.star.sheet.addin.Analysis.getHex2Oct
IMABS | com.sun.star.sheet.addin.Analysis.getImabs
IMAGINARY | com.sun.star.sheet.addin.Analysis.getImaginary
IMARGUMENT | com.sun.star.sheet.addin.Analysis.getImargument
IMCONJUGATE | com.sun.star.sheet.addin.Analysis.getImconjugate
IMCOS | com.sun.star.sheet.addin.Analysis.getImcos
IMCOSH | com.sun.star.sheet.addin.Analysis.getImcosh
IMCOT | com.sun.star.sheet.addin.Analysis.getImcot
IMCSC | com.sun.star.sheet.addin.Analysis.getImcsc
IMCSCH | com.sun.star.sheet.addin.Analysis.getImcsch
IMDIV | com.sun.star.sheet.addin.Analysis.getImdiv
IMEXP | com.sun.star.sheet.addin.Analysis.getImexp
IMLN | com.sun.star.sheet.addin.Analysis.getImln
IMLOG10 | com.sun.star.sheet.addin.Analysis.getImlog10
IMLOG2 | com.sun.star.sheet.addin.Analysis.getImlog2
IMPOWER | com.sun.star.sheet.addin.Analysis.getImpower
IMPRODUCT | com.sun.star.sheet.addin.Analysis.getImproduct
IMREAL | com.sun.star.sheet.addin.Analysis.getImreal
IMSEC | com.sun.star.sheet.addin.Analysis.getImsec
IMSECH | com.sun.star.sheet.addin.Analysis.getImsech
IMSIN | com.sun.star.sheet.addin.Analysis.getImsin
IMSINH | com.sun.star.sheet.addin.Analysis.getImsinh
IMSQRT | com.sun.star.sheet.addin.Analysis.getImsqrt
IMSUB | com.sun.star.sheet.addin.Analysis.getImsub
IMSUM | com.sun.star.sheet.addin.Analysis.getImsum
IMTAN | com.sun.star.sheet.addin.Analysis.getImtan
INTRATE | com.sun.star.sheet.addin.Analysis.getIntrate
ISEVEN | com.sun.star.sheet.addin.Analysis.getIseven
ISODD | com.sun.star.sheet.addin.Analysis.getIsodd
LCM | com.sun.star.sheet.addin.Analysis.getLcm
MDURATION | com.sun.star.sheet.addin.Analysis.getMduration
MROUND | com.sun.star.sheet.addin.Analysis.getMround
MULTINOMIAL | com.sun.star.sheet.addin.Analysis.getMultinomial
NETWORKDAYS | com.sun.star.sheet.addin.Analysis.getNetworkdays
NOMINAL | com.sun.star.sheet.addin.Analysis.getNominal
OCT2BIN | com.sun.star.sheet.addin.Analysis.getOct2Bin
OCT2DEC | com.sun.star.sheet.addin.Analysis.getOct2Dec
OCT2HEX | com.sun.star.sheet.addin.Analysis.getOct2Hex
ODDFPRICE | com.sun.star.sheet.addin.Analysis.getOddfprice
ODDFYIELD | com.sun.star.sheet.addin.Analysis.getOddfyield
ODDLPRICE | com.sun.star.sheet.addin.Analysis.getOddlprice
ODDLYIELD | com.sun.star.sheet.addin.Analysis.getOddlyield
PRICE | com.sun.star.sheet.addin.Analysis.getPrice
PRICEDISC | com.sun.star.sheet.addin.Analysis.getPricedisc
PRICEMAT | com.sun.star.sheet.addin.Analysis.getPricemat
QUOTIENT | com.sun.star.sheet.addin.Analysis.getQuotient
RANDBETWEEN | com.sun.star.sheet.addin.Analysis.getRandbetween
RECEIVED | com.sun.star.sheet.addin.Analysis.getReceived
SERIESSUM | com.sun.star.sheet.addin.Analysis.getSeriessum
SQRTPI | com.sun.star.sheet.addin.Analysis.getSqrtpi
TBILLEQ | com.sun.star.sheet.addin.Analysis.getTbilleq
TBILLPRICE | com.sun.star.sheet.addin.Analysis.getTbillprice
TBILLYIELD | com.sun.star.sheet.addin.Analysis.getTbillyield
WEEKNUM | com.sun.star.sheet.addin.Analysis.getWeeknum
WORKDAY | com.sun.star.sheet.addin.Analysis.getWorkday
XIRR | com.sun.star.sheet.addin.Analysis.getXirr
XNPV | com.sun.star.sheet.addin.Analysis.getXnpv
YEARFRAC | com.sun.star.sheet.addin.Analysis.getYearfrac
YIELD | com.sun.star.sheet.addin.Analysis.getYield
YIELDDISC | com.sun.star.sheet.addin.Analysis.getYielddisc
YIELDMAT | com.sun.star.sheet.addin.Analysis.getYieldmat

## ຊື່ບໍລິການ UNO ສຳລັບຟັງຊັນ Date Add-In

ຕາຕະລາງດ້ານລຸ່ມສະແດງລາຍການຟັງຊັນ Calc Date Add-In ທັງໝົດ ແລະ ຊື່ບໍລິການ UNO ທີ່ກົງກັນ.

ຊື່ຟັງຊັນ Calc | ຊື່ບໍລິການ UNO
--- | ---
DAYSINMONTH | com.sun.star.sheet.addin.DateFunctions.getDaysInMonth
DAYSINYEAR | com.sun.star.sheet.addin.DateFunctions.getDaysInMonth
MONTHS | com.sun.star.sheet.addin.DateFunctions.getDiffMonths
WEEKS | com.sun.star.sheet.addin.DateFunctions.getDiffWeeks
YEARS | com.sun.star.sheet.addin.DateFunctions.getDiffYears
ROT13 | com.sun.star.sheet.addin.DateFunctions.getRot13
WEEKSINYEAR | com.sun.star.sheet.addin.DateFunctions.getWeeksInYear

## ຊື່ບໍລິການ UNO ສຳລັບຟັງຊັນ Pricing Add-In

ຕາຕະລາງດ້ານລຸ່ມສະແດງລາຍການຟັງຊັນ Calc Pricing Add-In ທັງໝົດ ແລະ ຊື່ບໍລິການ UNO ທີ່ກົງກັນ.

ຊື່ຟັງຊັນ Calc | ຊື່ບໍລິການ UNO
--- | ---
OPT_BARRIER | com.sun.star.sheet.addin.PrincingFunctions.getOptBarrier
OPT_PROB_HIT | com.sun.star.sheet.addin.PrincingFunctions.getOptProbHit
OPT_PROB_INMONEY | com.sun.star.sheet.addin.PrincingFunctions.getOptProbInMoney
OPT_TOUCH | com.sun.star.sheet.addin.PrincingFunctions.getOptTouch

ຫົວຂໍ້ທີ່ກ່ຽວຂ້ອງ

ຟັງຊັນ CreateUnoService

ກະລຸນາສະໜັບສະໜູນພວກເຮົາ!