forked from pentaho/mondrian
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvba_functions.html
3820 lines (3810 loc) · 151 KB
/
vba_functions.html
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
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<html>
<!--
== This software is subject to the terms of the Eclipse Public License v1.0
== Agreement, available at the following URL:
== http://www.eclipse.org/legal/epl-v10.html.
== You must accept the terms of that agreement to use this software.
==
== Copyright (C) 2008-2009 Pentaho
== All Rights Reserved.
-->
<head>
<link rel="stylesheet" type="text/css" href="stylesheet.css"/>
<title>Pentaho Analysis Services: Visual Basic for Applications (VBA) Functions</title>
</head>
<body>
<!-- doc2web start -->
<!-- page title -->
<div class="contentheading">Visual Basic for Applications (VBA) Function List</div>
<!-- end page title -->
<p>The following table describes the functions in the Visual Basic for
Applications (VBA) specification, which are implicitly part of the MDX language
specification.</p>
<p>Some of the functions are not implemented in
mondrian, but are included for completeness. The 'Mondrian version/priority' column indicates which functions are
implemented in mondrian, and if not, priority of the development team for adding
them. Some functions, such as Beep, will never be implemented in Mondrian MDX.</p>
<p>The MDX language implemented by mondrian, including a list of set of
functions implemented, is described in the <a href="mdx.html">MDX specification</a>.</p>
<table style="border-collapse: collapse" border="1" width="500">
<tr><th>Name</th><th>Description</th><th>Mondrian version / priority</th></tr>
<tr><td>Abs</td><td>Returns a value of the same type that is passed to
it specifying the absolute value of a number.<br>
<br>
Syntax<br>
<br>
Abs(number)<br>
<br>
The required number argument can be any valid numeric expression. If number
contains Null, Null is returned; if it is an uninitialized variable, zero is
returned.<br>
<br>
Remarks<br>
<br>
The absolute value of a number is its unsigned magnitude. For example,
ABS(-1) and ABS(1) both return 1.</td><td>1</td></tr>
<tr><td>Add</td><td></td><td>-</td></tr>
<tr><td>AppActivate</td><td></td><td>-</td></tr>
<tr><td>Array</td><td>Returns a Variant containing an array.<br>
<br>
Syntax<br>
<br>
Array(arglist)<br>
<br>
The required arglist argument is a comma-delimited list of values that are
assigned to the elements of the array contained within the Variant. If no
arguments are specified, an array of zero length is created.<br>
<br>
Remarks<br>
<br>
The notation used to refer to an element of an array consists of the
variable name followed by parentheses containing an index number indicating
the desired element. In the following example, the first statement creates a
variable named <br>
A<br>
as a Variant. The second statement assigns an array to variable <br>
A<br>
. The last statement assigns the value contained in the second array element
to another variable.<br>
<br>
Dim A As Variant<br>
A = Array(10,20,30)<br>
B = A(2)<br>
The lower bound of an array created using the Array function is determined
by the lower bound specified with the Option Base statement, unless Array is
qualified with the name of the type library (for example VBA.Array). If
qualified with the type-library name, Array is unaffected by Option Base.<br>
<br>
Note A Variant that is not declared as an array can still contain an array.
A Variant variable can contain an array of any type, except fixed-length
strings and user-defined types. Although a Variant containing an array is
conceptually different from an array whose elements are of type Variant, the
array elements are accessed in the same way.</td><td>Not
applicable - mondrian has no array data type</td></tr>
<tr><td>Asc</td><td>Returns an Integer representing the character code
corresponding to the first letter in a string.<br>
<br>
Syntax<br>
<br>
Asc(string)<br>
<br>
The required string argument is any valid string expression. If the string
contains no characters, a run-time error occurs.<br>
<br>
Remarks<br>
<br>
The range for returns is 0 255 on non-DBCS systems, but 32768 32767 on DBCS
systems.<br>
<br>
Note The AscB function is used with byte data contained in a string. Instead
of returning the character code for the first character, AscB returns the
first byte. The AscW function returns the Unicode character code except on
platforms where Unicode is not supported, in which case, the behavior is
identical to the Asc function.</td><td>1</td></tr>
<tr><td>AscB</td><td>See Asc</td><td>N/A</td></tr>
<tr><td>AscW</td><td>See Asc</td><td>1</td></tr>
<tr><td>Atn</td><td>Returns a Double specifying the arctangent of a
number.<br>
<br>
Syntax<br>
<br>
Atn(number)<br>
<br>
The required number argument is a Double or any valid numeric expression.<br>
<br>
Remarks<br>
<br>
The Atn function takes the ratio of two sides of a right triangle (number)
and returns the corresponding angle in radians. The ratio is the length of
the side opposite the angle divided by the length of the side adjacent to
the angle.<br>
<br>
The range of the result is -pi/2 to pi/2 radians.<br>
<br>
To convert degrees to radians, multiply degrees by pi/180. To convert
radians to degrees, multiply radians by 180/pi.<br>
<br>
Note Atn is the inverse trigonometric function of Tan, which takes an angle
as its argument and returns the ratio of two sides of a right triangle. Do
not confuse Atn with the cotangent, which is the simple inverse of a tangent
(1/tangent).</td><td>1</td></tr>
<tr><td>Beep</td><td></td><td>Not applicable in server</td></tr>
<tr><td>Calendar</td><td></td><td>-</td></tr>
<tr><td>CallByName</td><td>Executes a method of an object, or sets or
returns a property of an object.<br>
<br>
Syntax<br>
<br>
CallByName(object, procname, calltype,[args()])<br>
<br>
The CallByName function syntax has these named arguments:<br>
<br>
Part Description <br>
object Required; Variant (Object). The name of the object on which the
function will be executed. <br>
procname Required; Variant (String). A string expression containing the name
of a property or method of the object. <br>
calltype Required; Constant. A constant of type vbCallType representing the
type of procedure being called. <br>
args() Optional: Variant (Array). <br>
<br>
Remarks<br>
<br>
The CallByName function is used to get or set a property, or invoke a method
at run time using a string name.<br>
<br>
In the following example, the first line uses CallByName to set the
MousePointer property of a text box, the second line gets the value of the
MousePointer property, and the third line invokes the Move method to move
the text box:<br>
<br>
CallByName Text1, "MousePointer", vbLet, vbCrosshair<br>
Result = CallByName (Text1, "MousePointer", vbGet)<br>
CallByName Text1, "Move", vbMethod, 100, 100</td><td>-</td></tr>
<tr><td>CBool</td><td>Returns an expression that has been converted to
a Variant of subtype Boolean.<br>
<br>
CBool(expression)<br>
<br>
The expression argument is any valid expression.<br>
<br>
If expression is zero, False is returned; otherwise, True is returned. If
expression can't be interpreted as a numeric value, a run-time error occurs.<br>
<br>
The following example uses the CBool function to convert an expression to a
Boolean. If the expression evaluates to a nonzero value, CBool returns True;
otherwise, it returns False. </td><td>2</td></tr>
<tr><td>CByte</td><td>Returns an expression that has been converted to
a Variant of subtype Byte.<br>
<br>
CByte(expression)<br>
<br>
The expression argument is any valid expression.<br>
<br>
In general, you can document your code using the subtype conversion
functions to show that the result of some operation should be expressed as a
particular data type rather than the default data type. For example, use
CByte to force byte arithmetic in cases where currency, single-precision,
double-precision, or integer arithmetic normally would occur.<br>
<br>
Use the CByte function to provide internationally aware conversions from any
other data type to a Byte subtype. For example, different decimal separators
are properly recognized depending on the locale setting of your system, as
are different thousand separators.<br>
<br>
If expression lies outside the acceptable range for the byte subtype, an
error occurs.</td><td>N/A; mondrian has no byte datatype</td></tr>
<tr><td>CCur</td><td>Returns an expression that has been converted to a
Variant of subtype Currency.<br>
<br>
CCur(expression)<br>
<br>
The expression argument is any valid expression.<br>
<br>
In general, you can document your code using the subtype conversion
functions to show that the result of some operation should be expressed as a
particular data type rather than the default data type. For example, use
CCur to force currency arithmetic in cases where integer arithmetic normally
would occur.<br>
<br>
You should use the CCur function to provide internationally aware
conversions from any other data type to a Currency subtype. For example,
different decimal separators and thousands separators are properly
recognized depending on the locale setting of your system.</td><td>-</td></tr>
<tr><td>CDate</td><td>Returns an expression that has been converted to
a Variant of subtype Date.<br>
<br>
CDate(date)<br>
<br>
The date argument is any valid date expression.<br>
<br>
Use the IsDate function to determine if date can be converted to a date or
time. CDate recognizes date literals and time literals as well as some
numbers that fall within the range of acceptable dates. When converting a
number to a date, the whole number portion is converted to a date. Any
fractional part of the number is converted to a time of day, starting at
midnight.<br>
<br>
CDate recognizes date formats according to the locale setting of your
system. The correct order of day, month, and year may not be determined if
it is provided in a format other than one of the recognized date settings.
In addition, a long date format is not recognized if it also contains the
day-of-the-week string.</td><td>1</td></tr>
<tr><td>CDbl</td><td>Returns an expression that has been converted to a
Variant of subtype Double.<br>
<br>
CDbl(expression)<br>
<br>
The expression argument is any valid expression.<br>
<br>
In general, you can document your code using the subtype conversion
functions to show that the result of some operation should be expressed as a
particular data type rather than the default data type. For example, use
CDbl or CSng to force double-precision or single-precision arithmetic in
cases where currency or integer arithmetic normally would occur.<br>
<br>
Use the CDbl function to provide internationally aware conversions from any
other data type to a Double subtype. For example, different decimal
separators and thousands separators are properly recognized depending on the
locale setting of your system.</td><td>2</td></tr>
<tr><td>CDec</td><td> </td><td> </td></tr>
<tr><td>ChDir</td><td> </td><td> </td></tr>
<tr><td>ChDrive</td><td> </td><td> </td></tr>
<tr><td>Choose</td><td> </td><td> </td></tr>
<tr><td>Chr</td><td>Returns a String containing the character
associated with the specified character code.<br>
<br>
Syntax<br>
<br>
Chr(charcode)<br>
<br>
The required charcode argument is a Long that identifies a character.<br>
<br>
Remarks<br>
<br>
Numbers from 0 31 are the same as standard, nonprintable ASCII codes. For
example, Chr(10) returns a linefeed character. The normal range for charcode
is 0 255. However, on DBCS systems, the actual range for charcode is -32768
to 65535.<br>
<br>
Note The ChrB function is used with byte data contained in a String. Instead
of returning a character, which may be one or two bytes, ChrB always returns
a single byte. The ChrW function returns a String containing the Unicode
character except on platforms where Unicode is not supported, in which case,
the behavior is identical to the Chr function.</td><td>1</td></tr>
<tr><td>ChrB</td><td>See Chr.</td><td>-</td></tr>
<tr><td>ChrW</td><td>See Chr.</td><td>1</td></tr>
<tr><td>CInt</td><td>Returns an expression that has been converted to a
Variant of subtype Integer.<br>
<br>
CInt(expression)<br>
<br>
The expression argument is any valid expression.<br>
<br>
In general, you can document your code using the subtype conversion
functions to show that the result of some operation should be expressed as a
particular data type rather than the default data type. For example, use
CInt or CLng to force integer arithmetic in cases where currency,
single-precision, or double-precision arithmetic normally would occur.<br>
<br>
Use the CInt function to provide internationally aware conversions from any
other data type to an Integer subtype. For example, different decimal
separators are properly recognized depending on the locale setting of your
system, as are different thousand separators.<br>
<br>
If expression lies outside the acceptable range for the Integer subtype, an
error occurs.<br>
<br>
The following example uses the CInt function to convert a value to an
Integer: <br>
<br>
Dim MyDouble, MyInt<br>
MyDouble = 2345.5678 ' MyDouble is a Double.<br>
MyInt = CInt(MyDouble) ' MyInt contains 2346.<p>Note. CInt differs from the
Fix and Int functions, which truncate, rather than round, the fractional
part of a number. When the fractional part is exactly 0.5, the CInt function
always rounds it to the nearest even number. For example, 0.5 rounds to 0,
and 1.5 rounds to 2.</td><td>2</td></tr>
<tr><td>Clear</td><td> </td><td> </td></tr>
<tr><td>CLng</td><td>Returns an expression that has been converted to a
Variant of subtype Long.<br>
<br>
CLng(expression)<br>
<br>
The expression argument is any valid expression.<br>
<br>
In general, you can document your code using the subtype conversion
functions to show that the result of some operation should be expressed as a
particular data type rather than the default data type. For example, use
CInt or CLng to force integer arithmetic in cases where currency,
single-precision, or double-precision arithmetic normally would occur.<br>
<br>
Use the CLng function to provide internationally aware conversions from any
other data type to a Long subtype. For example, different decimal separators
are properly recognized depending on the locale setting of your system, as
are different thousand separators.<br>
<br>
If expression lies outside the acceptable range for the Long subtype, an
error occurs.<br>
<br>
The following example uses the CLng function to convert a value to a Long:
<br>
<br>
Dim MyVal1, MyVal2, MyLong1, MyLong2<br>
MyVal1 = 25427.45: MyVal2 = 25427.55 ' MyVal1, MyVal2 are Doubles.<br>
MyLong1 = CLng(MyVal1) ' MyLong1 contains 25427.<br>
MyLong2 = CLng(MyVal2) ' MyLong2 contains 25428.<p>Note. CLng differs from
the Fix and Int functions, which truncate, rather than round, the fractional
part of a number. When the fractional part is exactly 0.5, the CLng function
always rounds it to the nearest even number. For example, 0.5 rounds to 0,
and 1.5 rounds to 2.</td><td>2</td></tr>
<tr><td>Command</td><td>Returns the argument portion of the command
line used to launch Microsoft Visual Basic or an executable program
developed with Visual Basic. <br>
<br>
Syntax<br>
<br>
Command<br>
<br>
Remarks<br>
<br>
When Visual Basic is launched from the command line, any portion of the
command line that follows <br>
/cmd<br>
is passed to the program as the command-line argument. In the following
example, <br>
cmdlineargs<br>
represents the argument information returned by the Command function.<br>
<br>
VB /cmd cmdlineargs<br>
For applications developed with Visual Basic and compiled to an .exe file,
Command returns any arguments that appear after the name of the application
on the command line. For example:<br>
<br>
MyApp cmdlineargs<br>
To find how command line arguments can be changed in the user interface of
the application you're using, search Help for "command line arguments."</td><td>
-</td></tr>
<tr><td>Cos</td><td>Returns a Double specifying the cosine of an angle.<br>
<br>
Syntax<br>
<br>
Cos(number)<br>
<br>
The required number argument is a Double or any valid numeric expression
that expresses an angle in radians.<br>
<br>
Remarks<br>
<br>
The Cos function takes an angle and returns the ratio of two sides of a
right triangle. The ratio is the length of the side adjacent to the angle
divided by the length of the hypotenuse.<br>
<br>
The result lies in the range -1 to 1.<br>
<br>
To convert degrees to radians, multiply degrees by pi/180. To convert
radians to degrees, multiply radians by 180/pi.</td><td>1</td></tr>
<tr><td>Count</td><td> </td><td>?</td></tr>
<tr><td>CreateObject</td><td>Creates and returns a reference to an
ActiveX object.<br>
<br>
Syntax<br>
<br>
CreateObject(class,[servername])<br>
<br>
The CreateObject function syntax has these parts:<br>
<br>
Part Description <br>
class Required; Variant (String). The application name and class of the
object to create. <br>
servername Optional; Variant (String). The name of the network server where
the object will be created. If servername is an empty string (""), the local
machine is used. <br>
<br>
The class argument uses the syntax appname.objecttype and has these parts:<br>
<br>
Part Description <br>
appname Required; Variant (String). The name of the application providing
the object. <br>
objecttype Required; Variant (String). The type or class of object to
create. <br>
<br>
Remarks<br>
<br>
Every application that supports Automation provides at least one type of
object. For example, a word processing application may provide an
Application object, a Document object, and a Toolbar object.</td><td>-</td></tr>
<tr><td>CSng</td><td> </td><td>?</td></tr>
<tr><td>CStr</td><td> </td><td>?</td></tr>
<tr><td>CurDir</td><td>Returns a Variant (String) representing the
current path.<br>
<br>
Syntax<br>
<br>
CurDir[(drive)]<br>
<br>
The optional drive argument is a string expression that specifies an
existing drive. If no drive is specified or if drive is a zero-length string
(""), CurDir returns the path for the current drive.</td><td> </td></tr>
<tr><td>Cvar</td><td> </td><td> </td></tr>
<tr><td>CVDate</td><td> </td><td> </td></tr>
<tr><td>CVErr</td><td>Returns a Variant of subtype Error containing an
error number specified by the user.<br>
<br>
Syntax<br>
<br>
CVErr(errornumber)<br>
<br>
The required errornumber argument is any valid error number.<br>
<br>
Remarks<br>
<br>
Use the CVErr function to create user-defined errors in user-created
procedures. For example, if you create a function that accepts several
arguments and normally returns a string, you can have your function evaluate
the input arguments to ensure they are within acceptable range. If they are
not, it is likely your function will not return what you expect. In this
event, CVErr allows you to return an error number that tells you what action
to take.<br>
<br>
Note that implicit conversion of an Error is not allowed. For example, you
can't directly assign the return value of CVErr to a variable that is not a
Variant. However, you can perform an explicit conversion (using CInt, CDbl,
and so on) of the value returned by CVErr and assign that to a variable of
the appropriate data type.</td><td>-</td></tr>
<tr><td>Date</td><td>Returns a Variant (Date) containing the current
system date.<br>
<br>
Syntax<br>
<br>
Date<br>
<br>
Remarks<br>
<br>
To set the system date, use the Date statement.<br>
<br>
Date, and if the calendar is Gregorian, Date$ behavior is unchanged by the
Calendar property setting. If the calendar is Hijri, Date$ returns a
10-character string of the form mm-dd-yyyy, where mm (01-12), dd (01-30) and
yyyy (1400-1523) are the Hijri month, day and year. The equivalent Gregorian
range is Jan 1, 1980 through Dec 31, 2099.</td><td>1</td></tr>
<tr><td>DateAdd</td><td>Returns a Variant (Date) containing a date to
which a specified time interval has been added.<br>
<br>
Syntax<br>
<br>
DateAdd(interval, number, date)<br>
<br>
The DateAdd function syntax has these named arguments:<br>
<br>
Part Description <br>
interval Required. String expression that is the interval of time you want
to add. <br>
number Required. Numeric expression that is the number of intervals you want
to add. It can be positive (to get dates in the future) or negative (to get
dates in the past). <br>
date Required. Variant (Date) or literal representing date to which the
interval is added. <br>
<br>
Settings<br>
<br>
The interval argument has these settings:<br>
<br>
Setting Description <br>
yyyy Year <br>
q Quarter <br>
m Month <br>
y Day of year <br>
d Day <br>
w Weekday <br>
ww Week <br>
h Hour <br>
n Minute <br>
s Second <br>
<br>
Remarks<br>
<br>
You can use the DateAdd function to add or subtract a specified time
interval from a date. For example, you can use DateAdd to calculate a date
30 days from today or a time 45 minutes from now.<br>
<br>
To add days to date, you can use Day of Year ("y"), Day ("d"), or Weekday
("w").<br>
<br>
The DateAdd function won't return an invalid date. The following example
adds one month to January 31:<br>
<br>
DateAdd("m", 1, "31-Jan-95")<br>
In this case, DateAdd returns 28-Feb-95, not 31-Feb-95. If date is
31-Jan-96, it returns 29-Feb-96 because 1996 is a leap year.<br>
<br>
If the calculated date would precede the year 100 (that is, you subtract
more years than are in date), an error occurs.<br>
<br>
If number isn't a Long value, it is rounded to the nearest whole number
before being evaluated.<br>
<br>
Note The format of the return value for DateAdd is determined by Control
Panel settings, not by the format that is passed in date argument.<br>
<br>
Note For date, if the Calendar property setting is Gregorian, the supplied
date must be Gregorian. If the calendar is Hijri, the supplied date must be
Hijri. If month values are names, the name must be consistent with the
current Calendar property setting. To minimize the possibility of month
names conflicting with the current Calendar property setting, enter numeric
month values (Short Date format).</td><td>1</td></tr>
<tr><td>DateDiff</td><td>Returns a Variant (Long) specifying the number
of time intervals between two specified dates.<br>
<br>
Syntax<br>
<br>
DateDiff(interval, date1, date2[, firstdayofweek[, firstweekofyear]])<br>
<br>
The DateDiff function syntax has these named arguments:<br>
<br>
Part Description <br>
interval Required. String expression that is the interval of time you use to
calculate the difference between date1 and date2. <br>
date1, date2 Required; Variant (Date). Two dates you want to use in the
calculation. <br>
firstdayofweek Optional. A constant that specifies the first day of the
week. If not specified, Sunday is assumed. <br>
firstweekofyear Optional. A constant that specifies the first week of the
year. If not specified, the first week is assumed to be the week in which
January 1 occurs. <br>
<br>
Settings<br>
<br>
The interval argument has these settings:<br>
<br>
Setting Description <br>
yyyy Year <br>
q Quarter <br>
m Month <br>
y Day of year <br>
d Day <br>
w Weekday <br>
ww Week <br>
h Hour <br>
n Minute <br>
s Second <br>
<br>
<br>
The firstdayofweek argument has these settings:<br>
<br>
Constant Value Description <br>
vbUseSystem 0 Use the NLS API setting. <br>
vbSunday 1 Sunday (default) <br>
vbMonday 2 Monday <br>
vbTuesday 3 Tuesday <br>
vbWednesday 4 Wednesday <br>
vbThursday 5 Thursday <br>
vbFriday 6 Friday <br>
vbSaturday 7 Saturday <br>
<br>
Constant Value Description <br>
vbUseSystem 0 Use the NLS API setting. <br>
vbFirstJan1 1 Start with week in which January 1 occurs (default). <br>
vbFirstFourDays 2 Start with the first week that has at least four days in
the new year. <br>
vbFirstFullWeek 3 Start with first full week of the year. <br>
<br>
<br>
Remarks<br>
<br>
You can use the DateDiff function to determine how many specified time
intervals exist between two dates. For example, you might use DateDiff to
calculate the number of days between two dates, or the number of weeks
between today and the end of the year.<br>
<br>
To calculate the number of days between date1 and date2, you can use either
Day of year ("y") or Day ("d"). When interval is Weekday ("w"), DateDiff
returns the number of weeks between the two dates. If date1 falls on a
Monday, DateDiff counts the number of Mondays until date2. It counts date2
but not date1. If interval is Week ("ww"), however, the DateDiff function
returns the number of calendar weeks between the two dates. It counts the
number of Sundays between date1 and date2. DateDiff counts date2 if it falls
on a Sunday; but it doesn't count date1, even if it does fall on a Sunday.<br>
<br>
If date1 refers to a later point in time than date2, the DateDiff function
returns a negative number.<br>
<br>
The firstdayofweek argument affects calculations that use the "w" and "ww"
interval symbols.<br>
<br>
If date1 or date2 is a date literal, the specified year becomes a permanent
part of that date. However, if date1 or date2 is enclosed in double
quotation marks (" "), and you omit the year, the current year is inserted
in your code each time the date1 or date2 expression is evaluated. This
makes it possible to write code that can be used in different years.<br>
<br>
When comparing December 31 to January 1 of the immediately succeeding year,
DateDiff for Year ("yyyy") returns 1 even though only a day has elapsed.<br>
<br>
Note For date1 and date2, if the Calendar property setting is Gregorian, the
supplied date must be Gregorian. If the calendar is Hijri, the supplied date
must be Hijri.</td><td>1</td></tr>
<tr><td>DatePart</td><td>Returns a Variant (Integer) containing the
specified part of a given date.<br>
<br>
Syntax<br>
<br>
DatePart(interval, date[,firstdayofweek[, firstweekofyear]])<br>
<br>
The DatePart function syntax has these named arguments:<br>
<br>
Part Description <br>
interval Required. String expression that is the interval of time you want
to return. <br>
date Required. Variant (Date) value that you want to evaluate. <br>
firstdayofweek Optional. A constant that specifies the first day of the
week. If not specified, Sunday is assumed. <br>
firstweekofyear Optional. A constant that specifies the first week of the
year. If not specified, the first week is assumed to be the week in which
January 1 occurs. <br>
<br>
Settings<br>
<br>
The interval argument has these settings:<br>
<br>
Setting Description <br>
yyyy Year <br>
q Quarter <br>
m Month <br>
y Day of year <br>
d Day <br>
w Weekday <br>
ww Week <br>
h Hour <br>
n Minute <br>
s Second <br>
<br>
The firstdayofweek argument has these settings:<br>
<br>
Constant Value Description <br>
vbUseSystem 0 Use the NLS API setting. <br>
vbSunday 1 Sunday (default) <br>
vbMonday 2 Monday <br>
vbTuesday 3 Tuesday <br>
vbWednesday 4 Wednesday <br>
vbThursday 5 Thursday <br>
vbFriday 6 Friday <br>
vbSaturday 7 Saturday <br>
<br>
The firstweekofyear argument has these settings:<br>
<br>
Constant Value Description <br>
vbUseSystem 0 Use the NLS API setting. <br>
vbFirstJan1 1 Start with week in which January 1 occurs (default). <br>
vbFirstFourDays 2 Start with the first week that has at least four days in
the new year. <br>
vbFirstFullWeek 3 Start with first full week of the year. <br>
<br>
Remarks<br>
<br>
You can use the DatePart function to evaluate a date and return a specific
interval of time. For example, you might use DatePart to calculate the day
of the week or the current hour.<br>
<br>
The firstdayofweek argument affects calculations that use the "w" and "ww"
interval symbols.<br>
<br>
If date is a date literal, the specified year becomes a permanent part of
that date. However, if date is enclosed in double quotation marks (" "), and
you omit the year, the current year is inserted in your code each time the
date expression is evaluated. This makes it possible to write code that can
be used in different years.<br>
<br>
Note For date, if the Calendar property setting is Gregorian, the supplied
date must be Gregorian. If the calendar is Hijri, the supplied date must be
Hijri.<br>
<br>
The returned date part is in the time period units of the current Arabic
calendar. For example, if the current calendar is Hijri and the date part to
be returned is the year, the year value is a Hijri year.</td><td>1</td></tr>
<tr><td>DateSerial</td><td>Returns a Variant (Date) for a specified
year, month, and day.<br>
<br>
Syntax<br>
<br>
DateSerial(year, month, day)<br>
<br>
The DateSerial function syntax has these named arguments:<br>
<br>
Part Description <br>
year Required; Integer. Number between 100 and 9999, inclusive, or a numeric
expression. <br>
month Required; Integer. Any numeric expression. <br>
day Required; Integer. Any numeric expression. <br>
<br>
<br>
Remarks<br>
<br>
To specify a date, such as December 31, 1991, the range of numbers for each
DateSerial argument should be in the accepted range for the unit; that is,
131 for days and 112 for months. However, you can also specify relative
dates for each argument using any numeric expression that represents some
number of days, months, or years before or after a certain date.<br>
<br>
The following example uses numeric expressions instead of absolute date
numbers. Here the DateSerial function returns a date that is the day before
the first day (<br>
1 - 1<br>
), two months before August (<br>
8 - 2<br>
), 10 years before 1990 (<br>
1990 - 10<br>
); in other words, May 31, 1980.<br>
<br>
DateSerial(1990 - 10, 8 - 2, 1 - 1)<br>
Under Windows 98 or Windows 2000, two digit years for the year argument are
interpreted based on user-defined machine settings. The default settings are
that values between 0 and 29, inclusive, are interpreted as the years
20002029. The default values between 30 and 99 are interpreted as the years
19301999. For all other year arguments, use a four-digit year (for example,
1800). <br>
<br>
Earlier versions of Windows interpret two-digit years based on the defaults
described above. To be sure the function returns the proper value, use a
four-digit year.<br>
<br>
When any argument exceeds the accepted range for that argument, it
increments to the next larger unit as appropriate. For example, if you
specify 35 days, it is evaluated as one month and some number of days,
depending on where in the year it is applied. If any single argument is
outside the range -32,768 to 32,767, an error occurs. If the date specified
by the three arguments falls outside the acceptable range of dates, an error
occurs.<br>
<br>
Note For year, month, and day, if the Calendar property setting is
Gregorian, the supplied value is assumed to be Gregorian. If the Calendar
property setting is Hijri, the supplied value is assumed to be Hijri.<br>
<br>
The returned date part is in the time period units of the current Visual
Basic calendar. For example, if the current calendar is Hijri and the date
part to be returned is the year, the year value is a Hijri year. For the
argument year, values between 0 and 99, inclusive, are interpreted as the
years 1400-1499. For all other year values, use the complete four-digit year
(for example, 1520).</td><td>1</td></tr>
<tr><td>DateValue</td><td>Returns a Variant (Date).<br>
<br>
Syntax<br>
<br>
DateValue(date)<br>
<br>
The required date argument is normally a string expression representing a
date from January 1, 100 through December 31, 9999. However, date can also
be any expression that can represent a date, a time, or both a date and
time, in that range.<br>
<br>
Remarks<br>
<br>
If date is a string that includes only numbers separated by valid date
separators, DateValue recognizes the order for month, day, and year
according to the Short Date format you specified for your system. DateValue
also recognizes unambiguous dates that contain month names, either in long
or abbreviated form. For example, in addition to recognizing 12/30/1991 and
12/30/91, DateValue also recognizes December 30, 1991 and Dec 30, 1991.<br>
<br>
If the year part of date is omitted, DateValue uses the current year from
your computer's system date.<br>
<br>
If the date argument includes time information, DateValue doesn't return it.
However, if date includes invalid time information (such as "89:98"), an
error occurs.<br>
<br>
Note For date, if the Calendar property setting is Gregorian, the supplied
date must be Gregorian. If the calendar is Hijri, the supplied date must be
Hijri. If the supplied date is Hijri, the argument date is a String
representing a date from 1/1/100 (Gregorian Aug 2, 718) through 4/3/9666
(Gregorian Dec 31, 9999).</td><td>1</td></tr>
<tr><td>Day</td><td>Returns a Variant
(Integer) specifying a whole number between 1
and 31, inclusive, representing the day of the
month.<br>
<br>
Syntax<br>
<br>
Day(date)<br>
<br>
The required date argument is any Variant,
numeric expression, string expression, or any
combination, that can represent a date. If date
contains Null, Null is returned.<br>
<br>
Note If the Calendar property setting is
Gregorian, the returned integer represents the
Gregorian day of the month for the date
argument. If the calendar is Hijri, the returned
integer represents the Hijri day of the month
for the date argument.</td><td>1</td></tr>
<tr><td>DDB</td><td>Returns a Double specifying the depreciation of an
asset for a specific time period using the double-declining balance method
or some other method you specify.<br>
<br>
Syntax<br>
<br>
DDB(cost, salvage, life, period[, factor])<br>
<br>
The DDB function has these named arguments:<br>
<br>
Part Description <br>
cost Required. Double specifying initial cost of the asset. <br>
salvage Required. Double specifying value of the asset at the end of its
useful life. <br>
life Required. Double specifying length of useful life of the asset. <br>
period Required. Double specifying period for which asset depreciation is
calculated. <br>
factor Optional. Variant specifying rate at which the balance declines. If
omitted, 2 (double-declining method) is assumed. <br>
<br>
<br>
Remarks<br>
<br>
The double-declining balance method computes depreciation at an accelerated
rate. Depreciation is highest in the first period and decreases in
successive periods.<br>
<br>
The life and period arguments must be expressed in the same units. For
example, if life is given in months, period must also be given in months.
All arguments must be positive numbers.<br>
<br>
The DDB function uses the following formula to calculate depreciation for a
given period:<br>
<br>
Depreciation / period = ((cost salvage) * factor) / life</td><td>2</td></tr>
<tr><td>Dir</td><td>Returns a String representing the name of a file,
directory, or folder that matches a specified pattern or file attribute, or
the volume label of a drive.<br>
<br>
Syntax<br>
<br>
Dir[(pathname[, attributes])]<br>
<br>
The Dir function syntax has these parts:<br>
<br>
Part Description <br>
pathname Optional. String expression that specifies a file name may include
directory or folder, and drive. A zero-length string ("") is returned if
pathname is not found. <br>
attributes Optional. Constant or numeric expression, whose sum specifies
file attributes. If omitted, returns files that match pathname but have no
attributes.<br>
<br>
Settings<br>
<br>
The attributes argument settings are:<br>
<br>
Constant Value Description <br>
vbNormal 0 (Default) Specifies files with no attributes. <br>
vbReadOnly 1 Specifies read-only files in addition to files with no
attributes. <br>
vbHidden 2 Specifies hidden files in addition to files with no attributes.
<br>
VbSystem 4 Specifies system files in addition to files with no attributes.
<br>
vbVolume 8 Specifies volume label; if any other attributed is specified,
vbVolume is ignored. <br>
vbDirectory 16 Specifies directories or folders in addition to files with no
attributes.<br>
<br>
Note These constants are specified by Visual Basic for Applications and can
be used anywhere in your code in place of the actual values..<br>
<br>
Remarks<br>
<br>
Dir supports the use of multiple character (*) and single character (?)
wildcards to specify multiple files.</td><td>-</td></tr>
<tr><td>DoEvents</td><td>Yields execution so that the operating system
can process other events.<br>
<br>
Syntax<br>
<br>
DoEvents( )<br>
<br>
Remarks<br>
<br>
The DoEvents function returns an Integer representing the number of open
forms in stand-alone versions of Visual Basic, such as Visual Basic,
Professional Edition. DoEvents returns zero in all other applications.<br>
<br>
DoEvents passes control to the operating system. Control is returned after
the operating system has finished processing the events in its queue and all
keys in the SendKeys queue have been sent.<br>
<br>
DoEvents is most useful for simple things like allowing a user to cancel a
process after it has started, for example a search for a file. For
long-running processes, yielding the processor is better accomplished by
using a Timer or delegating the task to an ActiveX EXE component.. In the
latter case, the task can continue completely independent of your
application, and the operating system takes case of multitasking and time
slicing.<br>
<br>
Caution Any time you temporarily yield the processor within an event
procedure, make sure the procedure is not executed again from a different
part of your code before the first call returns; this could cause
unpredictable results. In addition, do not use DoEvents if other
applications could possibly interact with your procedure in unforeseen ways
during the time you have yielded control.</td><td>-</td></tr>
<tr><td>DeleteSetting</td><td> </td><td> </td></tr>
<tr><td>Description</td><td> </td><td> </td></tr>
<tr><td>Environ</td><td>Returns the String associated with an
operating system environment variable. <br>
<br>
Syntax<br>
<br>
Environ({envstring | number})<br>
<br>
The Environ function syntax has these named arguments:<br>
<br>
Part Description <br>
envstring Optional. String expression containing the name of an environment
variable. <br>
number Optional. Numeric expression corresponding to the numeric order of
the environment string in the environment-string table. The number argument
can be any numeric expression, but is rounded to a whole number before it is
evaluated. <br>
<br>
<br>
Remarks<br>
<br>
If envstring can't be found in the environment-string table, a zero-length
string ("") is returned. Otherwise, Environ returns the text assigned to the
specified envstring; that is, the text following the equal sign (=) in the
environment-string table for that environment variable.<br>
<br>
If you specify number, the string occupying that numeric position in the
environment-string table is returned. In this case, Environ returns all of
the text, including envstring. If there is no environment string in the
specified position, Environ returns a zero-length string.</td><td>-</td></tr>
<tr><td>EOF</td><td>Returns an Integer containing the Boolean value
True when the end of a file opened for Random or sequential Input has been
reached.<br>
<br>
Syntax<br>
<br>
EOF(filenumber)<br>
<br>
The required filenumber argument is an Integer containing any valid file
number.<br>
<br>
Remarks<br>
<br>
Use EOF to avoid the error generated by attempting to get input past the end
of a file.<br>
<br>
The EOF function returns False until the end of the file has been reached.
With files opened for Random or Binary access, EOF returns False until the
last executed Get statement is unable to read an entire record.<br>
<br>
With files opened for Binary access, an attempt to read through the file
using the Input function until EOF returns True generates an error. Use the
LOF and Loc functions instead of EOF when reading binary files with Input,
or use Get when using the EOF function. With files opened for Output, EOF
always returns True.</td><td>-</td></tr>
<tr><td>Err</td><td>Contains information about run-time errors.<br>
<br>
Remarks<br>
The properties of the Err object are set by the generator of an error Visual
Basic, an object, or the programmer.<br>
<br>
The default property of the Err object is Number. Because the default
property can be represented by the object name Err, earlier code written
using the Err function or Err statement doesn't have to be modified.<br>
<br>
When a run-time error occurs, the properties of the Err object are filled