|
Visual Basic (VB and VBA) |
|
Copyright 1999-2001 Christopher Greaves. All rights reserved. Home Page and email to [email protected] |
| If in doubt, record a macro and inspect the entrails! |
Please read the DISCLAIMER.
Here is an INDEX to all the procedures.
You will probably need one copy of my GLOBAL DECLARATIONS.
Public Function strGetString(strSource As String, lngPointer As Long, strDelimiter As String, intOffset As Integer, strSeparator As String)
' Procedure : strGetString
' Description: Obtain a string from a library of strings.
' Copyright: Chris Greaves Inc
' Inputs: String library, pointer to the string, delimiter.
' Returns: a string from the string library.
' Assumes: None.
' Side Effects: None.
' Tested: By the calls shown below.
' Return a sub-string extracted from the source strSource.
' The left-most character is given as intPointer,
' The sub-string is delimited to the right by strDelimiter
' Within each string are substrings, separated by a separator
' We are to skip as many such sub-strings as counted in intOffset.
' Please see the test calls commented at the end of this procedure.
' Christopher Greaves
Dim lngP As Long
Dim lngQ As Long
Dim intI As Integer
'ProcsDim strSubString As String
If strSource = "" Then
strGetString = ""
Else
lngP = lngPointer ' Identify the NEXT pointer
lngQ = InStr(lngP + 1, strSource, strDelimiter)
intI = 0
While intI < intOffset
lngP = InStr(lngQ, strSource, strSeparator) + 1
lngQ = InStr(lngP, strSource, strSeparator)
intI = intI + 1
Wend
If lngQ < lngP Then
strGetString = ""
Else
strGetString = Mid(strSource, lngP, lngQ - lngP)
End If
End If
'Sub TESTstrGetString()
'Dim strLib As String: strLib = ""
'strLib = strPutString(strLib, "alpha", ",")
'strLib = strPutString(strLib, "beta", ",")
'strLib = strPutString(strLib, "gamma", ",")
'MsgBox strGetString(strLib, 0, ",", 3, ",")
'End Sub
End Function
| We all knew nothing when we started … |
|
Home Page and Contact Information Send email to [email protected]. This page was last updated Thursday, November 15, 2001 |