home *** CD-ROM | disk | FTP | other *** search
/ Freelog 52 / Freelog052.iso / Dossier / OpenOffice / f_0214 / Depot.xba < prev    next >
Extensible Markup Language  |  2002-11-21  |  17KB  |  494 lines

  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!DOCTYPE script:module PUBLIC "-//OpenOffice.org//DTD OfficeDocument 1.0//EN" "module.dtd">
  3. <script:module xmlns:script="http://openoffice.org/2000/script" script:name="Depot" script:language="StarBasic">Option Explicit
  4.  
  5.  
  6. Sub Initialize(Optional bChooseMarketPlace as Boolean)
  7. Dim bEnableHistory as Boolean
  8.     GlobalScope.BasicLibraries.LoadLibrary("Tools")
  9. '    oMarketModel = GetControlModel(oDocument.Sheets(0), "CmdHistory")
  10. '    bEnableHistory = oMarketModel.Enabled
  11.     ToggleWindow(False)
  12.     Today = Date()
  13.     bDebugmode = False
  14.     oDocument = ThisComponent
  15.     oController = oDocument.GetCurrentController
  16.     oSheets = oDocument.Sheets
  17.     oFirstSheet = oSheets(0)
  18.     oMovementSheet = oSheets(1)
  19.     oBankSheet = oSheets(2)
  20.     oDocFormats = oDocument.NumberFormats
  21.     oNumberFormatter = CreateUnoService("com.sun.star.util.NumberFormatter")
  22.     oNumberFormatter.AttachNumberFormatsSupplier(oDocument)
  23.     oDocLocale = oDocument.CharLocale
  24.     sDocLanguage = oDocLocale.Language
  25.     sDocCountry = oDocLocale.Country
  26.     LoadLanguage()
  27.     ToggleWindow(True)
  28. '    oMarketModel.Enabled = bEnableHistory
  29.     If Not IsMissing(bChooseMarketPlace) Then
  30.         If bChoosemarketPlace Then
  31.             ChooseMarket()
  32.         End If
  33.     Else
  34.         ChooseMarket()
  35.     End If
  36.     If Not IsMissing(bChooseMarketPlace) Then
  37.         If bChooseMarketPlace Then    
  38.             oMarketModel.Enabled = bEnableMarket    
  39.             oInternetModel.Enabled = bEnableInternet
  40.         End If
  41.     End If
  42. End Sub
  43.  
  44.  
  45. Sub Buy()
  46.     Initialize(True)
  47.      FillListbox(DlgTransaction.GetControl("lstBuyStocks"), TransactTitle(SBDIALOGBUY), False)
  48.     SetupTransactionControls(SBDIALOGBUY)
  49.     EnableTransactionControls(False)
  50.     DlgTransaction.Execute()
  51. End Sub
  52.  
  53.  
  54. Sub Sell()
  55.     Initialize(True)
  56.     If FillListbox(DlgTransaction.GetControl("lstSellStocks"), TransactTitle(SBDIALOGSELL), True) Then
  57.         SetupTransactionControls(SBDIALOGSELL)
  58.         EnableTransactionControls(False)
  59.         DlgTransaction.Execute()
  60.     End If
  61. End Sub
  62.  
  63.  
  64. Sub Reset()
  65. Dim TransactionCount as Integer
  66. Dim StockCount, iStartRow, i as Integer
  67. Dim oRows, oRange as Object
  68. Dim StockName as String
  69.     Initialize(True)
  70.     ' Delete transactions and reset overview
  71.     If MsgBox(sMsgDeleteAll, SBMSGYESNO+SBMSGQUESTION+SBMSGDEFAULTBTN2, sMsgAuthorization) = 6 Then
  72.         ' Assumption: If and only if there is an overview, then there are transactions, too
  73.         UnprotectSheets(oSheets)
  74.         StockCount = GetStocksCount(iStartRow)
  75.  
  76.         For i = 1 To StockCount
  77.             StockName = oFirstSheet.GetCellbyPosition(SBCOLUMNNAME1, iStartRow + i).String
  78.             If oSheets.HasbyName(StockName) Then
  79.                 oSheets.RemoveByName(StockName)
  80.             End If
  81.         Next
  82.         oDocument.AddActionLock
  83.         RemoveStockRows(oFirstSheet, iStartRow + 1, StockCount)
  84.         TransactionCount = GetTransactionCount(iStartRow)
  85.         RemoveStockRows(oMovementSheet, iStartRow + 2, TransactionCount)
  86.         ProtectSheets(oSheets)
  87.         oDocument.RemoveActionLock
  88.     End If
  89. End Sub
  90.  
  91.  
  92. Sub TransactionOk
  93. Dim Sold as Long
  94. Dim RestQuantity, Value, PartialValue, Profit
  95. Dim iNewRow as Integer, iRow as Integer
  96. Dim iStockRow as Long, iRestQuantity as Long
  97. Dim oNameCell as Object
  98. Dim CellStockName as String, SelStockName as String
  99. Dim CurRate as Double
  100. Dim TransactDate as Date
  101. Dim LocStockName as String
  102.     ' Check for rate entered
  103.     If TransactModel.txtRate.Value = 0 Then
  104.         If TransactModel.Step = SBDIALOGBUY Then
  105.             If MsgBox(sMsgFreeStock, SBMSGYESNO+SBMSGQUESTION, sMsgConfirm)=7 Then
  106.                 Exit Sub
  107.             End If
  108.         Else
  109.             If MsgBox(sMsgTotalLoss, SBMSGYESNO+SBMSGQUESTION, sMsgConfirm)=7 Then
  110.                 Exit Sub
  111.             End If
  112.         End If
  113.     End If
  114.     CurRate = TransactModel.txtRate.Value
  115.     TransactDate = CDateFromISO(TransactModel.txtDate.Date)
  116.     DlgTransaction.EndExecute()
  117.     UnprotectSheets(oSheets)
  118.  
  119.     iNewRow = DuplicateRow(oMovementSheet, "HiddenRow3")
  120.  
  121.     If TransactModel.Step = SBDIALOGBUY Then
  122.         CellStockName = TransactModel.lstBuyStocks.Text
  123.         If Instr(1,CellStockName,"$") <> 0 Then
  124.             CellStockName = "'" & CellStockName & "'"
  125.         End If
  126.         oMovementSheet.GetCellByPosition(SBCOLUMNNAME2, iNewRow).String = CellStockName
  127.         oMovementSheet.GetCellByPosition(SBCOLUMNQUANTITY2, iNewRow).Value = TransactModel.txtQuantity.Value
  128.     Else
  129.         CellStockName = DlgTransaction.GetControl("lstSellStocks").GetSelectedItem()
  130.         oMovementSheet.GetCellByPosition(SBCOLUMNNAME2, iNewRow).String = CellStockName
  131.         oMovementSheet.GetCellByPosition(SBCOLUMNQUANTITY2, iNewRow).Value = -TransactModel.txtQuantity.Value
  132.     End If
  133.     
  134.     oMovementSheet.GetCellByPosition(SBCOLUMNDATE2, iNewRow).Value = CDateFromISO(TransactModel.txtDate.Date)
  135.     oMovementSheet.GetCellByPosition(SBCOLUMNRATE2, iNewRow).Value = TransactModel.txtRate.Value
  136.     oMovementSheet.GetCellByPosition(SBCOLUMNPROVPERCENT2, iNewRow).Value = TransactModel.txtCommission.EffectiveValue
  137.     oMovementSheet.GetCellByPosition(SBCOLUMNPROVMIN2, iNewRow).Value = TransactModel.txtMinimum.Value
  138.     oMovementSheet.GetCellByPosition(SBCOLUMNPROVFIX2, iNewRow).Value = TransactModel.txtFix.Value
  139.     
  140.     ' Buy stocks: Update overview for new stocks
  141.     If TransactModel.Step = SBDIALOGBUY Then
  142.         iStockRow = GetStockRowIndex(CellStockName)
  143.         If iStockRow = -1 Then
  144.             iNewRow = DuplicateRow(oFirstSheet, "HiddenRow2")
  145.             oFirstSheet.GetCellByPosition(SBCOLUMNNAME1, iNewRow).String = CellStockName
  146.             oFirstSheet.GetCellByPosition(SBCOLUMNID1, iNewRow).String = TransactModel.txtStockID.Text
  147.             iStockRow = GetStockRowIndex(CellStockName)
  148.         End If
  149.     ' Sell stocks: Get transaction value, then update Transaction sheet
  150.     ElseIf TransactModel.Step = SBDIALOGSELL Then
  151.         Profit = oMovementSheet.GetCellByPosition(SBCOLUMNPROCEEDS2, iNewRow).Value
  152.         Value = Profit
  153.         Sold = TransactModel.txtQuantity.Value
  154.         SelStockName = DlgTransaction.GetControl("lstSellStocks").GetSelectedItem()
  155.         ' Go to first name
  156.         If TransactMode = FIFO Then
  157.             iRow = SBROWFIRSTTRANSACT2
  158.         Else
  159.             iRow = iNewRow-1
  160.         End If
  161.         
  162.         ' Check that no transaction after split date exists else cancel split
  163.         Do While Sold > 0
  164.             oNameCell = oMovementSheet.GetCellByPosition(SBCOLUMNNAME2, iRow)
  165.             CellStockName = oNameCell.String
  166.             If CellStockName = SelStockName Then
  167.                 ' Update transactions: Note quantity sold
  168.                 RestQuantity = oMovementSheet.GetCellByPosition(SBCOLUMNQTYREST2, iRow).Value
  169.                 ' If there still is a rest left ...
  170.                 If RestQuantity > 0 Then
  171.                     If RestQuantity < Sold Then
  172.                         ' Recalculate profit of new transaction
  173.                         Profit = Profit - oMovementSheet.GetCellByPosition(SBCOLUMNPRCREST2, iRow).Value    
  174.                         AddValueToCellContent(SBCOLUMNQTYSOLD2, iRow, RestQuantity)
  175.                         PartialValue = RestQuantity / Sold * Value
  176.                         AddValueToCellContent(SBCOLUMNREALPROC2, iRow, PartialValue)
  177.                         Sold = Sold - RestQuantity
  178.                         Value = Value - PartialValue
  179.                     Else
  180.                         ' Recalculate profit of neTransactModel.lstBuyStocks.Textw transaction
  181.                         PartialValue = oMovementSheet.GetCellByPosition(SBCOLUMNPRCREST2, iRow).Value    
  182.                         Profit = Profit - PartialValue/RestQuantity * Sold
  183.                         ' Update sold shares cell
  184.                         AddValueToCellContent(SBCOLUMNQTYSOLD2, iRow, Sold)
  185.                         ' Update sales turnover cell
  186.                         AddValueToCellContent(SBCOLUMNREALPROC2, iRow, Value)
  187.                         ' Update variables for rest of transaction
  188.                         Sold = 0
  189.                         Value = 0
  190.                     End If
  191.                 End If
  192.             End If
  193.             iRow = iRow + TransactMode
  194.         Loop
  195.         oMovementSheet.GetCellByPosition(SBCOLUMNREALPROFIT2,iNewRow).Value = Profit
  196.         iStockRow = GetStockRowIndex(SelStockName)    
  197.         iRestQuantity = oFirstSheet.GetCellbyPosition(SBCOLUMNQUANTITY1, iStockRow).Value
  198. '        If iRestQuantity = 0 Then
  199. '            If oSheets.HasbyName(SelStockName) Then
  200. '                oSheets.RemoveByName(SelStockName)
  201. '            End If
  202. '        Else
  203.             
  204. '        End If
  205.     End If
  206.     InsertCurrentValue(CurRate, iStockRow,TransactDate)    
  207.     ProtectSheets(oSheets)
  208. End Sub
  209.  
  210.  
  211. Sub SelectStockname()
  212. Dim iCurRow as Integer
  213. Dim CurStockName as String
  214.     With TransactModel
  215.         ' Find row with stock name
  216.         If TransactModel.Step = SBDIALOGBUY Then
  217.             CurStockName = .lstBuyStocks.Text
  218.             iCurRow = GetStockRowIndex(CurStockName)
  219.             .txtQuantity.ValueMax = 10000000
  220.         Else
  221.             CurStockName = DlgTransaction.GetControl("lstSellStocks").GetSelectedItem()
  222.             iCurRow = GetStockRowIndex(CurStockName)
  223.             .txtQuantity.Value = oFirstSheet.GetCellByPosition(SBCOLUMNQUANTITY1, iCurRow).Value
  224.             .txtQuantity.ValueMax = oFirstSheet.GetCellByPosition(SBCOLUMNQUANTITY1, iCurRow).Value
  225.             .txtRate.Value = oFirstSheet.GetCellbyPosition(SBCOLUMNRATE1, iCurRow).Value
  226.         End If
  227.         .txtStockID.Enabled = .Step = SBDIALOGBUY
  228.         .lblStockID.Enabled = .Step = SBDIALOGBUY    
  229.         ' Default settings for quantity and rate
  230.         .txtStockID.Text = GetStockID(CurStockName, iCurRow)
  231.     End With
  232.     EnableTransactionControls(CurStockName <> "")
  233.     TransactModel.cmdGoOn.DefaultButton = True
  234. End Sub
  235.  
  236.  
  237.  
  238. Sub HandleStocks(Mode as Integer, oDialog as Object)
  239. Dim DividendPerShare, DividendTotal, RestQuantity, OldValue
  240. Dim SelStockName, CellStockName as String
  241. Dim oNameCell as Object, oDateCell as Object
  242. Dim iRow as Integer
  243. Dim oDividendCell as Object
  244. Dim Amount
  245. Dim OldNumber, NewNumber as Integer
  246. Dim  NoteText as String
  247. Dim TotalStocksCount as Long
  248. Dim oModel as Object
  249.     oDocument.AddActionLock
  250.     oDialog.EndExecute()
  251.     oModel = oDialog.Model
  252.     SelStockName = DlgStockRates.GetControl("lstStockNames").GetSelectedItem()
  253.     Select Case Mode
  254.         Case HANDLEDIVIDEND
  255.             Dim bTakeTotal as Boolean
  256.             ' Update transactions: Enter dividend paid for all Buy transactions not sold completely
  257.             bTakeTotal = oModel.optTotal.State = 1
  258.             If bTakeTotal Then
  259.                 DividendTotal = oModel.txtDividend.Value
  260.                 iRow = GetStockRowIndex(SelStockName)
  261.                 TotalStocksCount = oFirstSheet.GetCellByPosition(SBCOLUMNQUANTITY1,iRow).Value
  262.                 DividendPerShare = DividendTotal/TotalStocksCount
  263.             Else
  264.                 DividendPerShare = oModel.txtDividend.Value
  265.             End If
  266.  
  267.         Case HANDLESPLIT
  268.             ' Store entered values in variables
  269.             OldNumber = oModel.txtOldRate.Value
  270.             NewNumber = oModel.txtNewRate.Value
  271.             SplitDate = CDateFromISO(oModel.txtDate.Date)
  272.             iRow = SBROWFIRSTTRANSACT2
  273.             NoteText = cSplit & SplitDate & ", " & oModel.txtOldRate.Value & oModel.lblColon.Label & oModel.txtNewRate.Value
  274.             Do 
  275.                 oNameCell = oMovementSheet.GetCellByPosition(SBCOLUMNNAME2, iRow)
  276.                 CellStockName = oNameCell.String
  277.                 If CellStockName = SelStockName Then
  278.                     oDateCell = oMovementSheet.GetCellByPosition(SBCOLUMNDATE2, iRow)
  279.                     If oDateCell.Value >= SplitDate Then
  280.                         MsgBox sMsgWrongExchangeDate, SBMSGOK + SBMSGSTOP, sMsgError                
  281.                         Exit Sub
  282.                     End If
  283.                 End If
  284.                 iRow = iRow + 1
  285.             Loop Until CellStockName = ""
  286.     End Select
  287.     iRow = SBROWFIRSTTRANSACT2
  288.     UnprotectSheets(oSheets)
  289.     Do
  290.         oNameCell = oMovementSheet.GetCellByPosition(SBCOLUMNNAME2, iRow)
  291.         CellStockName = oNameCell.String
  292.         If CellStockName = SelStockName Then
  293.             Select Case Mode
  294.                 Case HANDLEDIVIDEND
  295.                     RestQuantity = oMovementSheet.GetCellByPosition(SBCOLUMNQTYREST2, iRow).Value
  296.                     If RestQuantity > 0 Then
  297.                         oDividendCell = oMovementSheet.GetCellByPosition(SBCOLUMNDIVIDEND2, iRow)
  298.                         OldValue = oDividendCell.Value
  299.                         oDividendCell.Value = OldValue + RestQuantity * DividendPerShare
  300.                     End If
  301.                 Case HANDLESPLIT
  302.                     oDateCell = oMovementSheet.GetCellByPosition(SBCOLUMNDATE2, iRow)
  303.                      SplitCellValue(oMovementSheet, NewNumber, OldNumber, SBCOLUMNQUANTITY2, iRow, NoteText)            
  304.                      SplitCellValue(oMovementSheet, OldNumber, NewNumber, SBCOLUMNRATE2, iRow, "")
  305.                      SplitCellValue(oMovementSheet, NewNumber, OldNumber, SBCOLUMNQTYSOLD2, iRow, "")
  306.             End Select
  307.         End If
  308.         iRow = iRow + 1
  309.     Loop Until CellStockName = ""
  310.     If Mode = HANDLESPLIT Then
  311.          CalculateChartafterSplit(SelStockName, NewNumber, OldNumber, NoteText, SplitDate)
  312.     End If
  313.     oDocument.CalculateAll()
  314.     ProtectSheets(oSheets)
  315.     oDocument.RemoveActionLock
  316. End Sub
  317.  
  318.  
  319. Sub CancelStockRate()
  320.     DlgStockRates.EndExecute()
  321. End Sub
  322.  
  323.  
  324. Sub CancelTransaction()
  325.     DlgTransaction.EndExecute()
  326. End Sub
  327.  
  328.  
  329. Sub CommitStockRate()
  330. Dim CurStep as Integer
  331.     CurStep = StockRatesModel.Step
  332.     Select Case CurStep
  333.         Case 1
  334.             ' Check for quantity entered
  335.             If StockRatesModel.txtDividend.Value = 0 Then
  336.                 MsgBox sMsgNoDividend, SBMSGSTOP+SBMSGSTOP, sMsgError
  337.                 Exit Sub
  338.             End If
  339.             HandleStocks(HANDLEDIVIDEND, DlgStockRates)
  340.         Case 2
  341.             HandleStocks(HANDLESPLIT, DlgStockRates)
  342.         Case 3
  343.             InsertCompanyHistory()
  344.     End Select
  345. End Sub
  346.  
  347.  
  348. Sub EnableTransactionControls(bEnable as Boolean)
  349.     With TransactModel
  350.         .lblQuantity.Enabled = bEnable
  351.         .txtQuantity.Enabled = bEnable
  352.         .lblRate.Enabled = bEnable
  353.         .txtRate.Enabled = bEnable
  354.         .lblDate.Enabled = bEnable
  355.         .txtDate.Enabled = bEnable
  356.         .lblCommission.Enabled = bEnable
  357.         .txtCommission.Enabled = bEnable
  358.         .lblMinimum.Enabled = bEnable
  359.         .txtMinimum.Enabled = bEnable
  360.         .lblFix.Enabled = bEnable
  361.         .txtFix.Enabled = bEnable
  362.         If TransactModel.Step = SBDIALOGSELL Then
  363.             .cmdGoOn.Enabled = Ubound(TransactModel.lstSellStocks.SelectedItems()) > -1
  364.             DlgTransaction.GetControl("lstSellStocks").SetFocus()
  365.         Else
  366.             .cmdGoOn.Enabled = TransactModel.lstBuyStocks.Text <> ""
  367.             DlgTransaction.GetControl("lstBuyStocks").SetFocus()
  368.         End If
  369.         If bEnable Then
  370.             TransactModel.cmdGoOn.DefaultButton = True
  371.         End If
  372.     End With
  373. End Sub        
  374.  
  375.  
  376. Sub SetupTransactionControls(CurStep as Integer)
  377.     DlgReference = DlgTransaction
  378.     With TransactModel
  379.         .txtDate.Date = CDateToISO(Date())
  380.         .txtDate.DateMax = CDateToISO(Date())
  381.         .txtStockID.Enabled = False
  382.         .lblStockID.Enabled = False
  383.         .lblStockID.Label = sCurStockIDLabel
  384.         .txtRate.CurrencySymbol = sCurCurrency
  385.         .txtFix.CurrencySymbol = sCurCurrency
  386.         .Step = CurStep
  387.     End With
  388.     DlgTransaction.Title = TransactTitle(CurStep)
  389.     CellValuetoControl(oBankSheet, TransactModel.txtCommission, "ProvisionPercent")
  390.     CellValuetoControl(oBankSheet, TransactModel.txtMinimum, "ProvisionMinimum")
  391.     CellValuetoControl(oBankSheet, TransactModel.txtFix, "ProvisionFix")
  392. End Sub    
  393.  
  394.  
  395. Sub AddShortCuttoControl()
  396. Dim SelCompany as String
  397. Dim iRow, SelIndex as Integer
  398.     SelIndex = DlgTransaction.GetControl("lstBuyStocks").GetSelectedItemPos()
  399.     If SelIndex <> -1 Then
  400.         SelCompany = TransactModel.lstBuyStocks.StringItemList(SelIndex)
  401.         iRow = GetStockRowIndex(SelCompany)
  402.         If iRow <> -1 Then
  403.             TransactModel.txtStockID.Text = oFirstSheet.GetCellByPosition(SBCOLUMNID1,iRow).String
  404.             TransactModel.txtRate.Value = oFirstSheet.GetCellByPosition(SBCOLUMNRATE1,iRow).Value
  405.         Else
  406.             TransactModel.txtStockID.Text = ""
  407.             TransactModel.txtRate.Value = 0
  408.         End If
  409.     Else
  410.         TransactModel.txtStockID.Text = ""
  411.         TransactModel.txtRate.Value = 0
  412.     End If
  413. End Sub
  414.  
  415.  
  416. Sub OpenStockRatePage(aEvent)
  417. Dim CurStep as Integer
  418.     Initialize(True)
  419.     CurStep = aEvent.Source.Model.Tag
  420.     If FillListbox(DlgStockRates.GetControl("lstStockNames"), StockRatesTitle(CurStep), True) Then
  421.         StockRatesModel.Step = CurStep
  422.         ToggleStockRateControls(False, CurStep)    
  423.         InitializeStockRatesControls(CurStep)
  424.         DlgStockRates.Execute()
  425.     End If
  426. End Sub
  427.  
  428.  
  429. Sub SelectStockNameForRates()
  430. Dim StockName as String
  431.     StockName = DlgStockRates.GetControl("lstStockNames").GetSelectedItem()
  432.     If StockName <> "" Then
  433.         StockRatesModel.txtStockID.Text = GetStockID(StockName)
  434.         ToggleStockRateControls(True, StockRatesModel.Step)
  435.     End If
  436.     StockRatesModel.cmdGoOn.DefaultButton = True
  437. End Sub
  438.  
  439.  
  440. Sub ToggleStockRateControls(bDoEnable as Boolean, CurStep as Integer)    
  441.     With StockRatesModel
  442.         .lblStockID.Enabled = False
  443.         .txtStockID.Enabled = False
  444.         .cmdGoOn.Enabled = Ubound(StockRatesModel.lstStockNames.SelectedItems()) <> -1        
  445.         Select Case CurStep
  446.             Case 1
  447.                 .optPerShare.Enabled = bDoEnable
  448.                 .optTotal.Enabled = bDoEnable
  449.                 .lblDividend.Enabled = bDoEnable
  450.                 .txtDividend.Enabled = bDoEnable
  451.             Case 2
  452.                 .lblExchangeRate.Enabled = bDoEnable
  453.                 .lblDate.Enabled = bDoEnable
  454.                 .lblColon.Enabled = bDoEnable
  455.                 .txtOldRate.Enabled = bDoEnable
  456.                 .txtNewRate.Enabled = bDoEnable
  457.                 .txtDate.Enabled = bDoEnable
  458.             Case 3
  459.                 .lblStartDate.Enabled = bDoEnable
  460.                 .lblEndDate.Enabled = bDoEnable
  461.                 .txtStartDate.Enabled = bDoEnable
  462.                 .txtEndDate.Enabled = bDoEnable
  463.                 .hlnInterval.Enabled = bDoEnable
  464.                 .optDaily.Enabled = bDoEnable
  465.                 .optWeekly.Enabled = bDoEnable
  466.         End Select
  467.     End With
  468. End Sub
  469.  
  470.  
  471. Sub InitializeStockRatesControls(CurStep as Integer)
  472.     DlgReference = DlgStockRates
  473.     DlgStockRates.Title = StockRatesTitle(CurStep)
  474.     With StockRatesModel
  475.         .txtStockID.Text = ""
  476.         .lblStockID.Label = sCurStockIDLabel
  477.         Select Case CurStep
  478.             Case 1
  479.                 .txtDividend.Value = 0
  480.                 .optPerShare.State = 1
  481.                 .txtDividend.CurrencySymbol = sCurCurrency
  482.             Case 2
  483.                 .txtOldRate.Value = 1
  484.                 .txtNewRate.Value = 1
  485.                 .txtDate.Date = CDateToISO(Date())
  486.             Case 3
  487.                 .txtStartDate.DateMax = CDateToISO(CDate(Date())-1)
  488.                 .txtEndDate.DateMax = CDateToISO(CDate(Date())-1)
  489.                 .txtStartDate.Date = CDateToISO(CDate(Date())-8)
  490.                 .txtEndDate.Date = CDateToISO(CDate(Date())-1)
  491.                 .optDaily.State = 1
  492.         End Select
  493.     End With
  494. End Sub</script:module>