D
David C. Holley
I'm trying to create a procedure that parses out a comma-delimited
string and returns a specific value in it using the values ordinal
position. (ie. grab "test3" out of "test1", "test2", "test3", "test4")
formatOpenArgsString() successfully takes a string and breaks up as
needed placing quotes " before and after each value and maintaining the
commas
getOpenArguementValue() is creating the array, however its not parsing
out the value returned by formatOpenArgsString(). It is taking the
entire value and placing it into the array. The Array() does not appear
to be recognizing the commas returned by formatOpenArgsString()
formatOpenArgsString() in: test1, test2, test3, test4, test5
formatOpenArgsString() out: "test1", "test2", "test3", "test4", "test5"
getOpenArguementValue(0) out: "test1", "test2", "test3", "test4", "test5"
getOpenArguementValue(0) SHOULD be test1
but it is not.
Function getOpenArguementValue(strOpenArgs, intPosition)
Dim openArgsArray As Variant
openArgsArray = Array(formatOpenArgsString(strOpenArgs))
getOpenArguementValue = openArgsArray(intPosition)
End Function
Function formatOpenArgsString(strOpenArgs)
Dim strNewString As String
Dim i As Integer
Dim nextCharacter As String
strNewString = Chr(34)
For i = 1 To Len(strOpenArgs)
nextCharacter = Mid(strOpenArgs, i, 1)
Select Case nextCharacter
Case " "
Case ","
strNewString = strNewString & Chr(34) & ", " & Chr(34)
Case Else
strNewString = strNewString & nextCharacter
End Select
Next i
strNewString = strNewString & Chr(34)
Debug.Print strNewString
formatOpenArgsString = strNewString
End Function
string and returns a specific value in it using the values ordinal
position. (ie. grab "test3" out of "test1", "test2", "test3", "test4")
formatOpenArgsString() successfully takes a string and breaks up as
needed placing quotes " before and after each value and maintaining the
commas
getOpenArguementValue() is creating the array, however its not parsing
out the value returned by formatOpenArgsString(). It is taking the
entire value and placing it into the array. The Array() does not appear
to be recognizing the commas returned by formatOpenArgsString()
formatOpenArgsString() in: test1, test2, test3, test4, test5
formatOpenArgsString() out: "test1", "test2", "test3", "test4", "test5"
getOpenArguementValue(0) out: "test1", "test2", "test3", "test4", "test5"
getOpenArguementValue(0) SHOULD be test1
but it is not.
Function getOpenArguementValue(strOpenArgs, intPosition)
Dim openArgsArray As Variant
openArgsArray = Array(formatOpenArgsString(strOpenArgs))
getOpenArguementValue = openArgsArray(intPosition)
End Function
Function formatOpenArgsString(strOpenArgs)
Dim strNewString As String
Dim i As Integer
Dim nextCharacter As String
strNewString = Chr(34)
For i = 1 To Len(strOpenArgs)
nextCharacter = Mid(strOpenArgs, i, 1)
Select Case nextCharacter
Case " "
Case ","
strNewString = strNewString & Chr(34) & ", " & Chr(34)
Case Else
strNewString = strNewString & nextCharacter
End Select
Next i
strNewString = strNewString & Chr(34)
Debug.Print strNewString
formatOpenArgsString = strNewString
End Function