R
Ryan D
i found the following function for MS Access to sort text fields with
numbers. this code is excately what i need, however i need the function to
use two "strDelimit" variables, spitting the string based on two different
characters, a "-" and a ".", can anyone help me? thank you.
Public Function fSortSpecial(strIn, _
Optional strDelimit As String = ".", _
Optional LnumSize As Long = 3) As String
'strDelimit = character(s) used to split string
'lNumsize = minimum number of characters to use for number string
'This function is designed to handle only integer number strings
Dim vSplit As Variant
Dim strReturn As String
Dim i As Long
Dim sFormat as string
sFormat = String(LnumSize,"0")
If Len(strIn & "") = 0 Then
fSortSpecial = ""
Else
vSplit = Split(strIn, strDelimit)
For i = LBound(vSplit) To UBound(vSplit)
If IsNumeric(vSplit(i)) Then
strReturn = strReturn & _
Format(Val(vSplit(i)),sFormat) & strDelimit
Else
strReturn = strReturn & vSplit(i) & strDelimit
End If
Next i
fSortSpecial = strReturn
End If
End Function
numbers. this code is excately what i need, however i need the function to
use two "strDelimit" variables, spitting the string based on two different
characters, a "-" and a ".", can anyone help me? thank you.
Public Function fSortSpecial(strIn, _
Optional strDelimit As String = ".", _
Optional LnumSize As Long = 3) As String
'strDelimit = character(s) used to split string
'lNumsize = minimum number of characters to use for number string
'This function is designed to handle only integer number strings
Dim vSplit As Variant
Dim strReturn As String
Dim i As Long
Dim sFormat as string
sFormat = String(LnumSize,"0")
If Len(strIn & "") = 0 Then
fSortSpecial = ""
Else
vSplit = Split(strIn, strDelimit)
For i = LBound(vSplit) To UBound(vSplit)
If IsNumeric(vSplit(i)) Then
strReturn = strReturn & _
Format(Val(vSplit(i)),sFormat) & strDelimit
Else
strReturn = strReturn & vSplit(i) & strDelimit
End If
Next i
fSortSpecial = strReturn
End If
End Function