Visual Basic Deletefile

caching object references, 89 calendar (see date and time) Calendar property, 140-141 Call statement, 23, 141-142 callback functions, 121 CallByName function, 142-146

calling procedures, 23

case conversion (strings), 399-400, 565

CBool function, 31, 146

CByte function, 31, 147

CCur function, 32, 148-149

CDate function, 31, 149-151

CDbl function, 32, 151-152

CDec function, 31, 152-153

character variant data type, 30

characters case conversion, 399-400, 565 converting character codes to, 159-160

getting ANSI/Unicode codes, 129-132 ignoring when reading, 553 repeating into strings, 537-538 (see also strings) ChDir statement, 153-154 ChDrive statement, 155-156 Choose function, 156-158 Chr, Chr$, ChrB, ChrB$, ChrW

functions, 159-160 CInt function, 32, 160-161 class constructor/destructor (see

Initialize event; Terminate event) class methods calling from event handlers, 20-21 custom, 68-69 class modules, 54-76

creating ActiveX components, 70-75 events of, 63-68 private, 446 properties for, 70-72 classes, setting ability to save, 447 Clear method

BindingCollection object, 138 Err object, 254-255 Clear method (Err), 100 clearing (see deleting) CLng function, 32, 161-162 Close method (TextStream), 551 Close statement, 162-163 closing files, 162-163, 491, 551 cmdWordDoc_Click function

(example), 85 code (see program code) code modules class modules vs., 54 using at startup, 18

code reuse, 54

collection class, implementing For

Each...Next, 73 Collection object, 45, 49, 83-84, 164-173, 583 deleting members, 172-173 Dictionary objects vs. (ActiveX), 73 Exists property for, 74 mass assignation functions, 62 referencing members of, 83 stdDataFormats collection object, 531 (see also Dictionary object) Collection objects, custom

BindingCollection object, 134-139, 584

Drives collection object, 244-245, 586 Files collection object, 281-282, 588 Folders collection object, 318-319, 587

Printers collection object, 452-460 colors

QBColor function, 481-482 RGB function, 493-495 Command function, 173-175 command-line arguments parsing, 174 commands, intercepting (Microsoft

Word), 14 comments in program code, 488-489 CompareMode property (Dictionary), 225-226

comparing strings, 403-405, 445,

533-535 comparison operators, 607 compiler constants, defining, 113-117 conditional execution

If...Then...Else statement, 366-370 #If...Then...#Else directive, 117-119 IIf function, 370-371 Select Case statement, 506-508 Switch statement, 544-545 While...Wend statement, 573-574 (see also flow control) #Const directive, 113-117 Const statement, 175-176 constants declaring, 37-39, 175-176 enumerated constants, 62-63 intrinsic constants, 53, 598-605 constructor (see Initialize event)

converting between data types, 31-33,

146-154, 583 converting strings, 533, 535-537, 558

(see also strings) Copy method

File object, 271-272 Folder object, 314-315 CopyFile method (FileSystemObject), 283-284

CopyFolder method (FileSystemObject), 285-286

copying files, 271-272, 278-279,

283-284 copying folders, 285-286 Cos function, 176-177 cosines, 176-177

Count method (Collection), 49, 83, 168-169

Count property (Dictionary), 226 counting items (see Count method) CreateFolder method

(FileSystemObject), 286-287 CreateObject function, 78, 177-180

VB6 enhancements, 615 CreateTextFile method

FileSystemObject object, 287-289 Folder object, 315-316 creating (see Add method) CSng function, 32, 180-181 CStr function, 32, 181-182 CurDir, CurDir$ functions, 182 Currency data type, 27

converting to, 32, 148-149 custom applications, VBA for, 8 class methods, 68-69 events, 66-68, 266-268 Exists property, 74 procedures, 21-23 CVar function, 32, 182-183 CVDate function, 151, 183 CVErr function, 183-185

data binding, 47-50, 77-79

Binding object, 139-140, 584, 616 BindingCollection object, 134-139, 584, 616

Data Binding objects, 185-192, 584 DataBindingBehavior property, 193 email within VB (example), 86-88 performance, 48, 89 stdDataFormat object, 528-531 stdDataFormats collection object, 531 data consumer classes, 613 Data Format object, 616 data formatting

Data Format objects, 192-193 Format, Format$ functions, 325-334 FormatCurrency, FormatNumber, FormatPercent functions, 334-335

FormatDateTime function, 336-337 functions for (list), 590 stdDataFormat object, 528-531 stdDataFormats collection object, 531 data source classes, 613 data types, 26-37 checking, 92

converting between (VBA), 31-33,

146-154, 583 determining, 569-571 enumerated, 246-248 enumerated constants, 63 nothing, handling, 38 Property Get procedure and, 59 UDTs (user-defined types), 30, 45-46

properties as, 59-61 using default in declarations, 218-220 Variant (see Variant data type) data validation, 56

Let and custom events, 58 Property Let and custom events, 67 DataBindingBehavior property, 71 DataSourceBehavior property, 71, 194 date and time

CDate function, 31 Date data type, 27 vbCalendar type, 598 vbDateTimeFormat type, 599 vbDayOfWeek type, 599 vbFirstWeekOfYear type, 601 date and time functions (list), 584 Date data type, 31, 149-151 Date statement, 195-196 Date, Date$ functions, 194-195 DateAdd function, 196-198

DateDiff function, 198-201 DatePart function, 201-203 DateSerial function, 203-204 DateValue function, 205-208 Day function, 208-209 DDB function, 209-210 Deactivate event, 25 Debug object, 211-214 Decimal data type, 27

converting to, 31, 152-153 Declare statement, 214-218 declaring/defining arrays (see arrays) conditional compiler constants,

113-117 custom events, 67, 266-268 functions, 338-349 object variables, 67 object variables as Nothing, 104 references to external procedures, 214-218

storage space for variables, 232-236 sub procedures, 539-544 UDTs, 560-563

using default data types, 218-220 variables, 597

variables and constants, 37-39, 175-176

enumerated constants, 63, 246-248 errors when undefined, 445 object variables, 48 variant arrays, 125-129 Def... statements, 218-220 Delete method

File object, 272-273 Folder object, 316-317 DeleteFile method (FileSystemObject),

289-290 DeleteFolder method

(FileSystemObject), 290-291 DeleteSetting statement, 220-222 deleting (clearing) Binding objects from

BindingCollection, 138 Collection object members, 172-173 Dictionary keys and data, 231-232 Err object properties, 254-255 files, 272-273, 289-290, 397-398 folders, 290-291, 316-317, 496-498

forms from memory, 566-567 Registry keys and entries, 220-222 whitespace from strings, 420-421, 501, 559 depreciation, 209-210, 521-522,

545-546 Description property (Err), 100, 255-256

destructor (see Terminate event) dialog boxes, 379-381, 429-433 Dictionary object, 222-232, 585, 616 Dictionary objects

Collection objects vs. (ActiveX), 73 Dim statement, 37, 47, 232-236 dimensioning arrays (see arrays) Dir, Dir$ functions, 236-238 directory, working, 153-154 disk drives (see drives) division (/) operator, 606 division (\) operator (integer), 606 DLLs (see in-process ActiveX DLLs) Do...Loop statement, 239-241 Document_Open event (Word), 14 documentation on VB/VBA, viii documents, running programs when loading, 13, 16 DoEvents function, 241-242 Double data type, 28

converting to, 32, 151-152 double-declining balance depreciation, 209-210

drives

ChDrive statement, 155-156 Drive object, 242-244, 587 DriveExists method

(FileSystemObject), 291-292 Drives collection object, 244-245, 586 Drives property (FileSystemObject), 292

DriveTypeConst type, 600 GetDrive method (FileSystemObject),

295-296 GetDriveName method

(FileSystemObject), 297 working, changing, 155-156 dynamic arrays, 40-43 assigning, 614 multidimensional, 44 redimensioning, 486-488

(see also data binding) elements, array, 40

concatenating, 396-397 filtering out of arrays, 308-310 parsing strings into, 524-525 resetting values of, 252 email within VB (example), 86-88 Empty subtype (Variant), 34 encapsulation, 54 end of file, 249-252 End... statements, 25, 245-246 ending VB programs, 23-25 Enum statement, 63, 246-248 enumerated constants, 62-63, 246-248

intrinsic (built-in), 598-605 Environ, Environ$ functions, 248-249 environment variables, values of,

248-249 EOF function, 249-252 equal to (=) operator, 607 Eqv operator, 609 Erase statement, 252 Err object, 100, 253-264, 585 Error subtype (Variant), 34 errors, 91-107

in ActiveX servers, 101-104 checklist for handling, 92-95 CVErr function, 183-185 Err object, 100, 253-264, 585 error messages to users, 104 Error statement, 265-266 Error, Error$ functions, 265 handling in ActiveX components, 73 Help to prevent, 104 IsError function, 391-392 logging, 106

On Error statement, 440-442 in procedures, 95-100 for undefined variables, 445 event-driven programs, 11 events, 19

Automation Server, trapping, 84, 576-578

calling functions/methods upon, 20-21

of class modules, 63-68 custom, 66-68, 266-268

DoEvents function, 241-242 errors (see errors) event handlers, defined, 64 Event statement, 67, 266-268 explicitly creating, 23 firing (see firing events) keyboard key presses assigning VB macros to, 15, 17 simulating with SendKeys, 508-511 user actions, launching VB programs at, 14, 16 Excel (Microsoft), 6

running VBA modules, 15-17 VB output to (example), 88 executables (VB), running, 17 execution flow, 23, 594 EXEs (see out-of-process ActiveX EXEs) existence check

Dictionary keys, 226-227 drives, 291-292 files, 292-293 folders, 293-294 IsEmpty function, 390-391 IsMissing function, 393 IsNull function, 394 Exists method (Dictionary), 226-227 Exists property, 74 Exit statement, 268-269 Exit Sub statement, 99 Exp function, 269 exponentiation (A) operator, 607 extension, filename, 297-298 externally createable objects, 81

FileExists method (FileSystemObject),

292-293 filename extensions, 297-298 files accessing data from, 350-352, 376-379, 405-406, 552-553 Lock/Unlock statements with, 415-417, 567-568 CopyFile method (FileSystemObject),

283-284 copying (see copying files) CreateTextFile method

(FileSystemObject), 287-289

CreateTextFile method (Folder), 315-316

Delete method (Folder), 316-317 DeleteFile method

(FileSystemObject), 289-290 deleting, 272-273, 289-290, 397-398 Dir, Dir$ functions, 236-238 EOF function, 249-252 File object, 270-275, 588, 616 File System Folders collection, 616 File System object, 616 File System object model, 275-276 FileAttr function, 276-278 FileAttribute type, 600 FileCopy statement, 278-279 FileDateTime function, 279-280 FileExists method (FileSystemObject),

292-293 FileLen function, 280-281 Files collection object, 281-282, 588, 616

FileSystemObject object, 282-308, 586

FreeFile function, 337-338 GetAttr function, 355 GetExtensionName method

(FileSystemObject), 297-298 GetFile method (FileSystemObject),

298-299 GetFileName method

(FileSystemObject), 299-300 GetTempName method

(FileSystemObject), 303 handling (functions/statements list), 589

help files, 258-259 Move method (Folder), 317-318 MoveFile method (FileSystemObject), 303-304

opening/closing, 162-163, 274-275,

442-444, 491, 551 OpenTextFile method

(FileSystemObject), 306-308 read/write position, 415, 504-505 SetAttr function, 516-517 vbFileAttribute type, 600 width of, 574

writing to, 478-479, 554, 554-555,

578-579 (see also folders) Filter function, 308-310 finances

CCur function, 32 Currency data type, 27 FormatCurrency function, 334-335 functions for (list), 589 firing events custom events, 67, 482-483 Initialize event, 64 Terminate event, 65 first week of the year, 202 Fix function, 310-311 fixed arrays, 40 fixed-length strings, 29 floating point numbers converting to, 32, 151-152, 161-162, 180-181 data types for, 28 flow control, 23, 594 focus, setting to application, 123-125 folders

Add method (Folders), 319-320 Copy method (Folder), 314-315 CopyFolder method

(FileSystemObject), 285-286 CreateFolder method

(FileSystemObject), 286-287 CreateTextFile method (Folder),

316-317 creating new, 427 DeleteFolder method

(FileSystemObject), 290-291 deleting, 290-291, 316-317, 496-498 Dir, Dir$ functions, 236-238 File System Folders collection, 616 Folder object, 311-318, 587 FolderExists method

(FileSystemObject), 293-294 Folders collection object, 318-319, 587

Folders object, 616 GetAttr function, 355 GetFolder method

(FileSystemObject), 300-301

folders (continued)

GetParentFolderName method

(FileSystemObject), 301 GetSpecialFolder method

(FileSystemObject), 302-303 GetTempName method

(FileSystemObject), 303 handling (functions/statements list), 589

Move method (Folder), 317-318 MoveFolder method

(FileSystemObject), 304-306 SetAttr function, 516-517 SpecialFolderConst type, 603 (see also files) For Each...Next loops, 322-325 in ActiveX components, 72 implementing in custom collection objects, 73 iterating through collections, 84 For...Next statement, 320-322 Format, Format$ functions, 325-334 FormatCurrency, FormatNumber, FormatPercent functions, 334-335

FormatDateTime function, 336-337 formatting (see data formatting) forms binding controls (see data binding) defining properties in, 56 Form Load event, 17-18 loading into memory, 406-408 removing from memory, 566-567 running at startup, 17-18 unloading from memory, 24 FreeFile function, 337-338 Friend keyword, 47 friend scope class methods, 69 properties, 59 variables, 47 functions, 22, 112

Call statement, 141-142 calling, 20-21, 23 custom class methods, 68-69 defining (Function statement),

338-349 mass assignation functions, 62

new for VB6 (list), 615 returning arrays, 614 strongly typed, variants and, 37 sub procedures vs., 68, 94-95 (see also procedures) FV function, 349-350

0 0

Post a comment