summaryrefslogtreecommitdiff
path: root/wizards/source/depot/Depot.xba
blob: 358f3eaea3d765db69eae137d72f8d17572efd9c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE script:module PUBLIC "-//OpenOffice.org//DTD OfficeDocument 1.0//EN" "module.dtd">
<script:module xmlns:script="http://openoffice.org/2000/script" script:name="Depot" script:language="StarBasic">Option Explicit


Sub Initialize(Optional bChooseMarketPlace as Boolean)
Dim bEnableHistory as Boolean
	GlobalScope.BasicLibraries.LoadLibrary(&quot;Tools&quot;)
&apos;	oMarketModel = GetControlModel(oDocument.Sheets(0), &quot;CmdHistory&quot;)
&apos;	bEnableHistory = oMarketModel.Enabled
	ToggleWindow(False)
	Today = Date()
	bDebugmode = False
	oDocument = ThisComponent
	oController = oDocument.GetCurrentController
	oSheets = oDocument.Sheets
	oFirstSheet = oSheets(0)
	oMovementSheet = oSheets(1)
	oBankSheet = oSheets(2)
	oDocFormats = oDocument.NumberFormats
	oNumberFormatter = CreateUnoService(&quot;com.sun.star.util.NumberFormatter&quot;)
	oNumberFormatter.AttachNumberFormatsSupplier(oDocument)
	oDocLocale = oDocument.CharLocale
	sDocLanguage = oDocLocale.Language
	sDocCountry = oDocLocale.Country
	LoadLanguage()
	ToggleWindow(True)
&apos;	oMarketModel.Enabled = bEnableHistory
	If Not IsMissing(bChooseMarketPlace) Then
		If bChoosemarketPlace Then
			ChooseMarket()
		End If
	Else
		ChooseMarket()
	End If
	If Not IsMissing(bChooseMarketPlace) Then
		If bChooseMarketPlace Then	
			oMarketModel.Enabled = bEnableMarket	
			oInternetModel.Enabled = bEnableInternet
		End If
	End If
End Sub


Sub Buy()
	Initialize(True)
 	FillListbox(DlgTransaction.GetControl(&quot;lstBuyStocks&quot;), TransactTitle(SBDIALOGBUY), False)
	SetupTransactionControls(SBDIALOGBUY)
	EnableTransactionControls(False)
	DlgTransaction.Execute()
End Sub


Sub Sell()
	Initialize(True)
	If FillListbox(DlgTransaction.GetControl(&quot;lstSellStocks&quot;), TransactTitle(SBDIALOGSELL), True) Then
		SetupTransactionControls(SBDIALOGSELL)
		EnableTransactionControls(False)
		DlgTransaction.Execute()
	End If
End Sub


Sub Reset()
Dim TransactionCount as Integer
Dim StockCount, iStartRow, i as Integer
Dim oRows, oRange as Object
Dim StockName as String
	Initialize(True)
	&apos; Delete transactions and reset overview
	If MsgBox(sMsgDeleteAll, SBMSGYESNO+SBMSGQUESTION+SBMSGDEFAULTBTN2, sMsgAuthorization) = 6 Then
		&apos; Assumption: If and only if there is an overview, then there are transactions, too
		UnprotectSheets(oSheets)
		StockCount = GetStocksCount(iStartRow)

		For i = 1 To StockCount
			StockName = oFirstSheet.GetCellbyPosition(SBCOLUMNNAME1, iStartRow + i).String
			If oSheets.HasbyName(StockName) Then
				oSheets.RemoveByName(StockName)
			End If
		Next
		oDocument.AddActionLock
		RemoveStockRows(oFirstSheet, iStartRow + 1, StockCount)
		TransactionCount = GetTransactionCount(iStartRow)
		RemoveStockRows(oMovementSheet, iStartRow + 2, TransactionCount)
		ProtectSheets(oSheets)
		oDocument.RemoveActionLock
	End If
End Sub


Sub TransactionOk
Dim Sold as Long
Dim RestQuantity, Value, PartialValue, Profit
Dim iNewRow as Integer, iRow as Integer
Dim iStockRow as Long, iRestQuantity as Long
Dim oNameCell as Object
Dim CellStockName as String, SelStockName as String
Dim CurRate as Double
Dim TransactDate as Date
Dim LocStockName as String
	&apos; Check for rate entered
	If TransactModel.txtRate.Value = 0 Then
		If TransactModel.Step = SBDIALOGBUY Then
			If MsgBox(sMsgFreeStock, SBMSGYESNO+SBMSGQUESTION, sMsgConfirm)=7 Then
				Exit Sub
			End If
		Else
			If MsgBox(sMsgTotalLoss, SBMSGYESNO+SBMSGQUESTION, sMsgConfirm)=7 Then
				Exit Sub
			End If
		End If
	End If
	CurRate = TransactModel.txtRate.Value
	TransactDate = CDateFromISO(TransactModel.txtDate.Date)
	DlgTransaction.EndExecute()
	UnprotectSheets(oSheets)

	iNewRow = DuplicateRow(oMovementSheet, &quot;HiddenRow3&quot;)

	If TransactModel.Step = SBDIALOGBUY Then
		CellStockName = TransactModel.lstBuyStocks.Text
		If Instr(1,CellStockName,&quot;$&quot;) &lt;&gt; 0 Then
			CellStockName = &quot;&apos;&quot; &amp; CellStockName &amp; &quot;&apos;&quot;
		End If
		oMovementSheet.GetCellByPosition(SBCOLUMNNAME2, iNewRow).String = CellStockName
		oMovementSheet.GetCellByPosition(SBCOLUMNQUANTITY2, iNewRow).Value = TransactModel.txtQuantity.Value
	Else
		CellStockName = DlgTransaction.GetControl(&quot;lstSellStocks&quot;).GetSelectedItem()
		oMovementSheet.GetCellByPosition(SBCOLUMNNAME2, iNewRow).String = CellStockName
		oMovementSheet.GetCellByPosition(SBCOLUMNQUANTITY2, iNewRow).Value = -TransactModel.txtQuantity.Value
	End If
	
	oMovementSheet.GetCellByPosition(SBCOLUMNDATE2, iNewRow).Value = CDateFromISO(TransactModel.txtDate.Date)
	oMovementSheet.GetCellByPosition(SBCOLUMNRATE2, iNewRow).Value = TransactModel.txtRate.Value
	oMovementSheet.GetCellByPosition(SBCOLUMNPROVPERCENT2, iNewRow).Value = TransactModel.txtCommission.EffectiveValue
	oMovementSheet.GetCellByPosition(SBCOLUMNPROVMIN2, iNewRow).Value = TransactModel.txtMinimum.Value
	oMovementSheet.GetCellByPosition(SBCOLUMNPROVFIX2, iNewRow).Value = TransactModel.txtFix.Value
	
	&apos; Buy stocks: Update overview for new stocks
	If TransactModel.Step = SBDIALOGBUY Then
		iStockRow = GetStockRowIndex(CellStockName)
		If iStockRow = -1 Then
			iNewRow = DuplicateRow(oFirstSheet, &quot;HiddenRow2&quot;)
			oFirstSheet.GetCellByPosition(SBCOLUMNNAME1, iNewRow).String = CellStockName
			oFirstSheet.GetCellByPosition(SBCOLUMNID1, iNewRow).String = TransactModel.txtStockID.Text
			iStockRow = GetStockRowIndex(CellStockName)
		End If
	&apos; Sell stocks: Get transaction value, then update Transaction sheet
	ElseIf TransactModel.Step = SBDIALOGSELL Then
		Profit = oMovementSheet.GetCellByPosition(SBCOLUMNPROCEEDS2, iNewRow).Value
		Value = Profit
		Sold = TransactModel.txtQuantity.Value
		SelStockName = DlgTransaction.GetControl(&quot;lstSellStocks&quot;).GetSelectedItem()
		&apos; Go to first name
		If TransactMode = FIFO Then
			iRow = SBROWFIRSTTRANSACT2
		Else
			iRow = iNewRow-1
		End If
		
		&apos; Check that no transaction after split date exists else cancel split
		Do While Sold &gt; 0
			oNameCell = oMovementSheet.GetCellByPosition(SBCOLUMNNAME2, iRow)
			CellStockName = oNameCell.String
			If CellStockName = SelStockName Then
				&apos; Update transactions: Note quantity sold
				RestQuantity = oMovementSheet.GetCellByPosition(SBCOLUMNQTYREST2, iRow).Value
				&apos; If there still is a rest left ...
				If RestQuantity &gt; 0 Then
					If RestQuantity &lt; Sold Then
						&apos; Recalculate profit of new transaction
						Profit = Profit - oMovementSheet.GetCellByPosition(SBCOLUMNPRCREST2, iRow).Value	
						AddValueToCellContent(SBCOLUMNQTYSOLD2, iRow, RestQuantity)
						PartialValue = RestQuantity / Sold * Value
						AddValueToCellContent(SBCOLUMNREALPROC2, iRow, PartialValue)
						Sold = Sold - RestQuantity
						Value = Value - PartialValue
					Else
						&apos; Recalculate profit of neTransactModel.lstBuyStocks.Textw transaction
						PartialValue = oMovementSheet.GetCellByPosition(SBCOLUMNPRCREST2, iRow).Value	
						Profit = Profit - PartialValue/RestQuantity * Sold
						&apos; Update sold shares cell
						AddValueToCellContent(SBCOLUMNQTYSOLD2, iRow, Sold)
						&apos; Update sales turnover cell
						AddValueToCellContent(SBCOLUMNREALPROC2, iRow, Value)
						&apos; Update variables for rest of transaction
						Sold = 0
						Value = 0
					End If
				End If
			End If
			iRow = iRow + TransactMode
		Loop
		oMovementSheet.GetCellByPosition(SBCOLUMNREALPROFIT2,iNewRow).Value = Profit
		iStockRow = GetStockRowIndex(SelStockName)	
		iRestQuantity = oFirstSheet.GetCellbyPosition(SBCOLUMNQUANTITY1, iStockRow).Value
&apos;		If iRestQuantity = 0 Then
&apos;			If oSheets.HasbyName(SelStockName) Then
&apos;				oSheets.RemoveByName(SelStockName)
&apos;			End If
&apos;		Else
			
&apos;		End If
	End If
	InsertCurrentValue(CurRate, iStockRow,TransactDate)	
	ProtectSheets(oSheets)
End Sub


Sub SelectStockname(aEvent as Object)
Dim iCurRow as Integer
Dim CurStockName as String
	With TransactModel
		&apos; Find row with stock name
		If TransactModel.Step = SBDIALOGBUY Then
			CurStockName = .lstBuyStocks.Text
			iCurRow = GetStockRowIndex(CurStockName)
			.txtQuantity.ValueMax = 10000000
		Else
			Dim ListBoxList() as String
			ListBoxList() = GetSelectedListboxItems(aEvent.Source.getModel())
			CurStockName = ListBoxList(0)
&apos;			CurStockName = DlgTransaction.GetControl(aEvent.Source.getModel.Name).GetSelectedItem()
			iCurRow = GetStockRowIndex(CurStockName)
			Dim fdouble as Double
			fdouble = oFirstSheet.GetCellByPosition(SBCOLUMNQUANTITY1, iCurRow).Value
			.txtQuantity.Value = fdouble
			.txtQuantity.ValueMax = oFirstSheet.GetCellByPosition(SBCOLUMNQUANTITY1, iCurRow).Value
			.txtRate.Value = oFirstSheet.GetCellbyPosition(SBCOLUMNRATE1, iCurRow).Value
		End If
		.txtStockID.Enabled = .Step = SBDIALOGBUY
		.lblStockID.Enabled = .Step = SBDIALOGBUY	
		&apos; Default settings for quantity and rate
		.txtStockID.Text = GetStockID(CurStockName, iCurRow)
	End With
	EnableTransactionControls(CurStockName &lt;&gt; &quot;&quot;)
	TransactModel.cmdGoOn.DefaultButton = True
End Sub



Sub HandleStocks(Mode as Integer, oDialog as Object)
Dim DividendPerShare, DividendTotal, RestQuantity, OldValue
Dim SelStockName, CellStockName as String
Dim oNameCell as Object, oDateCell as Object
Dim iRow as Integer
Dim oDividendCell as Object
Dim Amount
Dim OldNumber, NewNumber as Integer
Dim  NoteText as String
Dim TotalStocksCount as Long
Dim oModel as Object
	oDocument.AddActionLock
	oDialog.EndExecute()
	oModel = oDialog.Model
	SelStockName = DlgStockRates.GetControl(&quot;lstStockNames&quot;).GetSelectedItem()
	Select Case Mode
		Case HANDLEDIVIDEND
			Dim bTakeTotal as Boolean
			&apos; Update transactions: Enter dividend paid for all Buy transactions not sold completely
			bTakeTotal = oModel.optTotal.State = 1
			If bTakeTotal Then
				DividendTotal = oModel.txtDividend.Value
				iRow = GetStockRowIndex(SelStockName)
				TotalStocksCount = oFirstSheet.GetCellByPosition(SBCOLUMNQUANTITY1,iRow).Value
				DividendPerShare = DividendTotal/TotalStocksCount
			Else
				DividendPerShare = oModel.txtDividend.Value
			End If

		Case HANDLESPLIT
			&apos; Store entered values in variables
			OldNumber = oModel.txtOldRate.Value
			NewNumber = oModel.txtNewRate.Value
			SplitDate = CDateFromISO(oModel.txtDate.Date)
			iRow = SBROWFIRSTTRANSACT2
			NoteText = cSplit &amp; SplitDate &amp; &quot;, &quot; &amp; oModel.txtOldRate.Value &amp; oModel.lblColon.Label &amp; oModel.txtNewRate.Value
			Do 
				oNameCell = oMovementSheet.GetCellByPosition(SBCOLUMNNAME2, iRow)
				CellStockName = oNameCell.String
				If CellStockName = SelStockName Then
					oDateCell = oMovementSheet.GetCellByPosition(SBCOLUMNDATE2, iRow)
					If oDateCell.Value &gt;= SplitDate Then
						MsgBox sMsgWrongExchangeDate, SBMSGOK + SBMSGSTOP, sMsgError				
						Exit Sub
					End If
				End If
				iRow = iRow + 1
			Loop Until CellStockName = &quot;&quot;
	End Select
	iRow = SBROWFIRSTTRANSACT2
	UnprotectSheets(oSheets)
	Do
		oNameCell = oMovementSheet.GetCellByPosition(SBCOLUMNNAME2, iRow)
		CellStockName = oNameCell.String
		If CellStockName = SelStockName Then
			Select Case Mode
				Case HANDLEDIVIDEND
					RestQuantity = oMovementSheet.GetCellByPosition(SBCOLUMNQTYREST2, iRow).Value
					If RestQuantity &gt; 0 Then
						oDividendCell = oMovementSheet.GetCellByPosition(SBCOLUMNDIVIDEND2, iRow)
						OldValue = oDividendCell.Value
						oDividendCell.Value = OldValue + RestQuantity * DividendPerShare
					End If
				Case HANDLESPLIT
					oDateCell = oMovementSheet.GetCellByPosition(SBCOLUMNDATE2, iRow)
				 	SplitCellValue(oMovementSheet, NewNumber, OldNumber, SBCOLUMNQUANTITY2, iRow, NoteText)			
		 			SplitCellValue(oMovementSheet, OldNumber, NewNumber, SBCOLUMNRATE2, iRow, &quot;&quot;)
				 	SplitCellValue(oMovementSheet, NewNumber, OldNumber, SBCOLUMNQTYSOLD2, iRow, &quot;&quot;)
			End Select
		End If
		iRow = iRow + 1
	Loop Until CellStockName = &quot;&quot;
	If Mode = HANDLESPLIT Then
	 	CalculateChartafterSplit(SelStockName, NewNumber, OldNumber, NoteText, SplitDate)
	End If
	oDocument.CalculateAll()
	ProtectSheets(oSheets)
	oDocument.RemoveActionLock
End Sub


Sub CancelStockRate()
	DlgStockRates.EndExecute()
End Sub


Sub CancelTransaction()
	DlgTransaction.EndExecute()
End Sub


Sub CommitStockRate()
Dim CurStep as Integer
	CurStep = StockRatesModel.Step
	Select Case CurStep
		Case 1
			&apos; Check for quantity entered
			If StockRatesModel.txtDividend.Value = 0 Then
				MsgBox sMsgNoDividend, SBMSGSTOP+SBMSGSTOP, sMsgError
				Exit Sub
			End If
			HandleStocks(HANDLEDIVIDEND, DlgStockRates)
		Case 2
			HandleStocks(HANDLESPLIT, DlgStockRates)
		Case 3
			InsertCompanyHistory()
	End Select
End Sub


Sub EnableTransactionControls(bEnable as Boolean)
	With TransactModel
		.lblQuantity.Enabled = bEnable
		.txtQuantity.Enabled = bEnable
		.lblRate.Enabled = bEnable
		.txtRate.Enabled = bEnable
		.lblDate.Enabled = bEnable
		.txtDate.Enabled = bEnable
		.lblCommission.Enabled = bEnable
		.txtCommission.Enabled = bEnable
		.lblMinimum.Enabled = bEnable
		.txtMinimum.Enabled = bEnable
		.lblFix.Enabled = bEnable
		.txtFix.Enabled = bEnable
		If TransactModel.Step = SBDIALOGSELL Then
			.cmdGoOn.Enabled = Ubound(TransactModel.lstSellStocks.SelectedItems()) &gt; -1
			DlgTransaction.GetControl(&quot;lstSellStocks&quot;).SetFocus()
		Else
			.cmdGoOn.Enabled = TransactModel.lstBuyStocks.Text &lt;&gt; &quot;&quot;
			DlgTransaction.GetControl(&quot;lstBuyStocks&quot;).SetFocus()
		End If
		If bEnable Then
			TransactModel.cmdGoOn.DefaultButton = True
		End If
	End With
End Sub		


Sub SetupTransactionControls(CurStep as Integer)
	DlgReference = DlgTransaction
	With TransactModel
		.txtDate.Date = CDateToISO(Date())
		.txtDate.DateMax = CDateToISO(Date())
		.txtStockID.Enabled = False
		.lblStockID.Enabled = False
		.lblStockID.Label = sCurStockIDLabel
		.txtRate.CurrencySymbol = sCurCurrency
		.txtFix.CurrencySymbol = sCurCurrency
		.Step = CurStep
	End With
	DlgTransaction.Title = TransactTitle(CurStep)
	CellValuetoControl(oBankSheet, TransactModel.txtCommission, &quot;ProvisionPercent&quot;)
	CellValuetoControl(oBankSheet, TransactModel.txtMinimum, &quot;ProvisionMinimum&quot;)
	CellValuetoControl(oBankSheet, TransactModel.txtFix, &quot;ProvisionFix&quot;)
End Sub	


Sub AddShortCuttoControl()
Dim SelCompany as String
Dim iRow, SelIndex as Integer
	SelIndex = DlgTransaction.GetControl(&quot;lstBuyStocks&quot;).GetSelectedItemPos()
	If SelIndex &lt;&gt; -1 Then
		SelCompany = TransactModel.lstBuyStocks.StringItemList(SelIndex)
		iRow = GetStockRowIndex(SelCompany)
		If iRow &lt;&gt; -1 Then
			TransactModel.txtStockID.Text = oFirstSheet.GetCellByPosition(SBCOLUMNID1,iRow).String
			TransactModel.txtRate.Value = oFirstSheet.GetCellByPosition(SBCOLUMNRATE1,iRow).Value
		Else
			TransactModel.txtStockID.Text = &quot;&quot;
			TransactModel.txtRate.Value = 0
		End If
	Else
		TransactModel.txtStockID.Text = &quot;&quot;
		TransactModel.txtRate.Value = 0
	End If
End Sub


Sub OpenStockRatePage(aEvent)
Dim CurStep as Integer
	Initialize(True)
	CurStep = aEvent.Source.Model.Tag
	If FillListbox(DlgStockRates.GetControl(&quot;lstStockNames&quot;), StockRatesTitle(CurStep), True) Then
		StockRatesModel.Step = CurStep
		ToggleStockRateControls(False, CurStep)	
		InitializeStockRatesControls(CurStep)
		DlgStockRates.Execute()
	End If
End Sub


Sub SelectStockNameForRates()
Dim StockName as String
	StockName = DlgStockRates.GetControl(&quot;lstStockNames&quot;).GetSelectedItem()
	If StockName &lt;&gt; &quot;&quot; Then
		StockRatesModel.txtStockID.Text = GetStockID(StockName)
		ToggleStockRateControls(True, StockRatesModel.Step)
	End If
	StockRatesModel.cmdGoOn.DefaultButton = True
End Sub


Sub ToggleStockRateControls(bDoEnable as Boolean, CurStep as Integer)	
	With StockRatesModel
		.lblStockID.Enabled = False
		.txtStockID.Enabled = False
		.cmdGoOn.Enabled = Ubound(StockRatesModel.lstStockNames.SelectedItems()) &lt;&gt; -1		
		Select Case CurStep
			Case 1
				.optPerShare.Enabled = bDoEnable
				.optTotal.Enabled = bDoEnable
				.lblDividend.Enabled = bDoEnable
				.txtDividend.Enabled = bDoEnable
			Case 2
				.lblExchangeRate.Enabled = bDoEnable
				.lblDate.Enabled = bDoEnable
				.lblColon.Enabled = bDoEnable
				.txtOldRate.Enabled = bDoEnable
				.txtNewRate.Enabled = bDoEnable
				.txtDate.Enabled = bDoEnable
			Case 3
				.lblStartDate.Enabled = bDoEnable
				.lblEndDate.Enabled = bDoEnable
				.txtStartDate.Enabled = bDoEnable
				.txtEndDate.Enabled = bDoEnable
				.hlnInterval.Enabled = bDoEnable
				.optDaily.Enabled = bDoEnable
				.optWeekly.Enabled = bDoEnable
		End Select
	End With
End Sub


Sub InitializeStockRatesControls(CurStep as Integer)
	DlgReference = DlgStockRates
	DlgStockRates.Title = StockRatesTitle(CurStep)
	With StockRatesModel
		.txtStockID.Text = &quot;&quot;
		.lblStockID.Label = sCurStockIDLabel
		Select Case CurStep
			Case 1
				.txtDividend.Value = 0
				.optPerShare.State = 1
				.txtDividend.CurrencySymbol = sCurCurrency
			Case 2
				.txtOldRate.Value = 1
				.txtNewRate.Value = 1
				.txtDate.Date = CDateToISO(Date())
			Case 3
				.txtStartDate.DateMax = CDateToISO(CDate(Date())-1)
				.txtEndDate.DateMax = CDateToISO(CDate(Date())-1)
				.txtStartDate.Date = CDateToISO(CDate(Date())-8)
				.txtEndDate.Date = CDateToISO(CDate(Date())-1)
				.optDaily.State = 1
		End Select
	End With
End Sub
</script:module>