|
|
CSS 341 - Fundamentals
of Programming Theory and Application Most examples due to Kelvin Sung |
|
Lecture Week/Date |
What |
For Download |
|
Week 8 |
File Selector uses either Common Dialog Box or the File Dialog from within Excel to select files for opening. | FileSelector.vbs |
| Example with Strings. Gives examples of string manipulation functions, including split and filter. | ExampleWithStrings.vbs | |
| Parse a path name after selecting file | FileNameAndExtensionFromFullPath.vbs | |
|
|
Dictionary. This is a
useful object (think utility tool)
that the VB runtime environment gives us. 1. In this example, we want to have some idea on how to use
existing utilities written by others. We see that we must understand what the
utility does, and must understand how to use the interface functions. 2. Another important lesson learned in this example is: how
to iterate through an existing
collection
of objects. |
|
|
Using Dictionary:
Read from a data file, process, save as text output and as a word document.
Here is the data TextFile. 1.
OpenTextFileAsStream: now supports input and output stream. We can open an
existing file for writing, and/or create a new file for writing. 2.
ReadInputStreamToDictionary: reading text into the dictionary. Since we know a little
about the input format, we will perform 2 reads per input line, to parse out
the 9-digit ID. 3.
SaveDictionaryToFile:
Save processed dictionary into another text file. Notice, we reuse the
OpenTextFileAsStream function here. 4.
CreateDocFromDictionary: Simple output routine, writing the dictionary to MS Word
file. Making it look decent. |
||
|
|
Working with Database: This is a Microsoft Access database file. Let’s see what is in there.
We should look at the tables, and the queries. |
|
|
|
ActiveX Interface to Database:
This is ActiveX interface to Microsoft Access Database. ActiveX interface does
not support database operations well. We need something else! |
|
|
|
Active Data Object ( |
|
|
|
More |
|
|
|
||
|
ADO Interface to
query with a user-entered parameter.
The query MajorsFromEnteredState asks the user to enter a
state abbreviation.
This script shows how to enter this information from vbs. |
|
|
|
|