Depot.xba 18 KB

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