Total Visual SourceBook

Total Visual SourceBook CD and Printed Manual

Microsoft Access/ Office 2016, 2013, 2010, and 2007 Version
is Shipping!

New features in Total Visual SourceBook for Access, Office 2007 and VB6

Supports Access/Office 2016, 2013, 2010 and 2007, and Visual Basic 6.0!

Separate version for Access/Office 2003, 2002, and 2000.

Separate version for:
Access 97/95

View all FMS products for Microsoft AccessAll Our Microsoft Access Products

SourceBook Info:

Why SourceBook?


"The code is exactly how I would like to write code and the algorithms used are very efficient and well-documented."

Van T. Dinh, Microsoft MVP




Microsoft Access, Office/VBA, VB6 Modules royalty-free source code libraryMicrosoft Access Modules royalty-free source code libraryMicrosoft Access VBA and VB6 Module Library Free trial of Total Visual SourceBook for Microsoft Access, Office, VB6 and VBA

Class: CommandArgs in Category Microsoft Visual Basic 6 : Application Techniques from Total Visual SourceBook

Class to parse information contained in a string into individual parts that can be tested in VBA and VB6.

Procedure List

Procedure Name



(Declarations) Declarations Declarations and private variables for the CCommandArgs class
Count Property Number of key/value pairs found. This property is invalid until Parse is called.
Delim Property Get the character used to delimit keys from values.
Item Property Get the Item property of the passed index. If a numeric value is passed to the property, then the value is looked up by index. If a string value is passed to the property, the value is looked up by key value. Invalid until the Parse method is called.
Key Property Get the Key/Value pair at the specified index value. For example if intIndex is 0, the value of the first key is returned. This property is invalid until Parse is called.
TestString Property Get the value of the TestString property.
Value Property Get the value at the specified index location. For example if intIndex is 0, the first value is returned.
Parse Method Parse the current value of the TestString property. Before calling this method, assign the string to be tested to the TestString property and assign a delimiter character to the Delim property of the class. The Key, Item, Value, and Count properties are invalid until this method is called.

Example Code for Using Class: CommandArgs

' Example of the CCommandArgs class
' To try this example, do the following:
' 1. Create a new form
' 2. Create a text box called 'txtTestString'
' 3. Create a text box called 'txtSearch'
' 4. Create a command button called 'cmdParse'
' 5. Create a command button called 'cmdSearch'
' 6. Paste all the code from this example to the new form's module
' 7. Run the form.
'     - Press the cmdParse button to parse the command line contained in the txtTestString text box.
'     - Press the cmdSearch button to search for a particular key value.

' In the Declarations section of the form define the variable
Private mStartString As CCommandArgs

Private Sub Form_Load()

  ' Add a caption to the buttons
  Me.cmdSearch.Caption = "Search"
  Me.cmdParse.Caption = "Parse"

  ' Instantiate the variable, and set any desired properties
  Set mStartString = New CCommandArgs
  mStartString.Delim = "/"

  ' Provide a sample test string to parse
  txtTestString = "/Name Smith /Pwd My Password /Title Supervisor"

  ' Provide a sample word to search for
  txtSearch = "Pwd"

End Sub

Private Sub cmdParse_Click()
  ' Parse out the input string contained in the "txtTestString" text box.
  ' Display each item in a message box

  Dim intCounter As Integer

  If txtTestString <> "" Then

    ' Assign the string to test
    mStartString.TestString = txtTestString

    ' Parse the test string

    ' Loop through each item, and display the key and value found
    For intCounter = 1 To mStartString.Count
      MsgBox "Key: " & mStartString.Key(intCounter) & vbCrLf & _
             "Value: " & mStartString.Value(intCounter)

    Next intCounter

  End If

End Sub

Private Sub cmdSearch_Click()
  ' Display the Item corresponding to the key indicated in the txtSearch text box

  MsgBox mStartString.Item(txtSearch)

End Sub

Microsoft Access Module LibraryOverview of Total Visual SourceBook

The source code in Total Visual SourceBook includes modules and classes for Microsoft Access, Visual Basic 6 (VB6), and Visual Basic for Applications (VBA) developers. Easily add this professionally written, tested, and documented royalty-free code into your applications to simplify your application development efforts.

Additional Resources