[AccessD] A2003:Replacing 'tokens' in a string

Stuart McLachlan stuart at lexacorp.com.pg
Tue Jan 26 22:33:04 CST 2010


Note: the function below does not require the square brackets around the Token.
Usage:  Getvalue(strTokenList, "InvoiceNo")

If you want to use the brackets in the call to allow for a case where the token name may also 
appear in another token's value, you will need to change the 2 to 1 in the code and the  call 
would be:  Getvalue(strTokenList, "[InvoiceNo]")

Function GetValue(TokenList As String, Token As String) As String
Dim lngStart As Long
Dim lngEnd As Long
lngStart = InStr(TokenList, Token) + Len(Token) + 2
lngEnd = InStr(lngStart, TokenList, """")
GetValue = Mid$(TokenList, lngStart, lngEnd - lngStart)
End Function

-- 
Stuart

On 27 Jan 2010 at 13:31, Darren - Active Billing wrote:

> Hi team
> 
> Assuming the string below
> 
> "[AccountNo]=1234","[InvoiceNo]=1234567","[InvoiceDate]=04/01/2010","[Name]=
> Barry"
> 
> How would I get just the Invoice Number bit = Eg 1234567?
> 
> The 'token' [InvoiceNo] will be constant followed by an "=" sign
> 
> But sadly the position of the [InvoiceNo] token in the string will not be
> constant - Otherwise I'd just use MID()
> 
> Nor will the length of the invoice number - Some may be 4 digits others 6
> etc
> 
> I need to pull just the Invoice Number (And the Account Number) out of the
> string to build a new string being used elsewhere
> 
> Many thanks in advance
> 
> Darren
> 
>  
> 
> -- 
> AccessD mailing list
> AccessD at databaseadvisors.com
> http://databaseadvisors.com/mailman/listinfo/accessd
> Website: http://www.databaseadvisors.com





More information about the AccessD mailing list