simple question:using the output of a function into a sub procedure

Leen

Registered User.
Local time
Today, 08:05
Joined
Mar 15, 2007
Messages
56
Hi,

I think this is a very stupid question, but for one reason it doesn't work.

I have in my code:
Code:
Public reftablename As String
Public reffield As String
Public field As String

Then I created a function:
Code:
Function regexpparts(inputfield As String) 'As String 'find all parts of the inputfield
    Dim regEx As Object
    Set regEx = CreateObject("vbscript.regexp")
    
    With regEx
        .Pattern = "(\b\w+?\b)"
        .Global = True 'find all matches
    End With
    
    Set matches = regEx.Execute(inputfield)
    'number = matches.Count
    reftablename = matches(0) '=name of the reference table
    reffield = matches(1) '=reffield
    field = matches(2) '=field
    
    Set matches = Nothing
    Set regEx = Nothing
End Function

The aim is, that, when I run this function on an inputfield (in a sub procedure), this function returns te values of the variables "reftablename"/"reffield"/"field".

It works when calling the following function in a sub procedure:
Code:
regexpparts (values)

However, I'd like to have explicitly mentioned in my function, the output it has to return, so I wanted to start my function with:

Code:
Function regexpparts(inputfield As String, reftablename as string, reffield as string, field as string)

However, if I change it into the above line, I get the error when I call the procedure, namely: "Argument not optional"

How exactly can I specify in the function the variables it has to return?
Thanks!
Leen
 

Users who are viewing this thread

Back
Top Bottom