ParseText Function

dgriffis1231

Registered User.
Local time
Today, 17:58
Joined
Oct 9, 2013
Messages
25
I have entered the function below in the vba module:

Public Function ParseText()
On Error Resume Next
Dim var As Variant
var = Split(TextIn, " ", -1)
ParseText = var(X)
End Function

but when I try to execute: ParseText([Expression],1) It replies "Undefined fuction "ParseText' in expression". I apologize if there is a simple solution to this question. I am new to VBA and creating functions.

Thank-you,

dgriffis
 
The function should be in a standard module rather than a form/report module; is it? I assume the actual function and call arguments match up?
 
Out of the three selections - module, class module, procedure. I selected module. It is correct that the function name in the code is the same that I used in the query call.
 
Module is correct, but make sure the module doesn't have the same name as the function. Yes, your call would use the function name.
 
You have called the function by passing a variable. But the function you have declared doesn't have a variable.

Try..

Public Function ParseText(TextIn as String) As String

The last bit "As String" declares that the returned variable is a string.

hth
Chris
 
The OP was calling the function with two variables [Expression] and 1

So the function call should be
Public Function ParseText(TextIn as String, Rubbish as integer) As String
 
I have updated the module with

Public Function ParseText(TextIn As String) As String

However in the query entry: ParseText([Expression],1)

It replys:

"The expression you entered has a function containing the wrong number of arguments."
 
Yes, you also need X which you use in the function.

Public Function ParseText(TextIn As String, X As Integer) As String
 

Users who are viewing this thread

Back
Top Bottom