David Anderson
Registered User.
- Local time
- Today, 06:19
- Joined
- Nov 18, 2007
- Messages
- 84
I think your standard module function will look something like:
Code:Option Compare Database Option Explicit Function SelectWords(InString As String, InCount As Integer) As String '-- Return a string with InCount words from the InString supplied separated by one space as a delimiter Dim MyArray() As String Dim x As Integer SelectWords = "" '-- Initialize the return value If Len(InString) > 0 Then MyArray = Split(InString, " ") If UBound(MyArray) > 0 Then '-- We have some array elements For x = 0 To UBound(MyArray) - 1 SelectWords = Trim(MyArray(x)) '-- Add a trailing space as a delimiter SelectWords = SelectWords & " " Next '-- Strip off the last space SelectWords = left(SelectWords, Len(SelectWords) - 1) End If End If End Function
Allan,
Yours is the first solution I have started to evaluate but I was immediately confused by the fact that the InCount parameter is not actually used in your code! Being unfamiliar with programming arrays, I have not yet worked out how to fix this....
David