so onto another issue with the following function:
Public Function dhExtractString(ByVal strIn As String, ByVal intPiece As Integer, _
Optional ByVal strDelimiter As String = dhcDelimiters) As String
Dim lngPos As Long
Dim lngpos1 As Long
Dim lngLastPos As Long
Dim intLoop As Integer
lngPos = 0
lngLastPos = 0
intLoop = intPiece
'if there's more that on delimiter, map them all to the first one
If Len(strDelimiter) > 1 Then
strIn = dhTranslate(strIn, strDelimiter, Left$(strDelimitier, 1))
End If
strIn = dhTrimAll(strIn)
Do While intLoop > 0
lngLastPos = lngPos
lngpos1 = InStr(lngPos + 1, strIn, Left$(strDelimiter, 1))
If lngpos1 > 0 Then
lngPos = lngpos1
intLoop = intLoop - 1
Else
lngPos = Len(strIn) + 1
Exit Do
End If
Loop
End Function
no matter what i try, it always says "Constant expression required" even though it's optional. here is what i tried to use:
Public Sub TestExtract(strIniText As String)
Const dhcdelimiters As String = "=,"
Dim intI As Integer
Dim strText As String
dhcdelimiters = "=,"
intI = 2
Do While True
strText = dhExtractString(strIniText, intI, "=,")
If Len(strText) = 0 Then
Exit Do
End If
Debug.Print strText
intI = intI + 1
Loop
End Sub
Sub test_E_nw()
Const dhcdelimiters As String = "=,"
dhcdelimiters = "=,"
Debug.Print TestExtract("ItemsToBuy=Milk,Bread,Peas")
End Sub
even if i add dhcDelimiters to the function, it still fails at the function. what am i implementing wrong?
Bookmarks