Function with for loop - How to return in vb | UFT

408 Views Asked by At

I would need support for that. I guess it's an easy one but i would like to get different approach if possible. I have the following Function and i just want to return value. If possible within a string variable.

StrVal = "123 Test"

Function IsHaving(StrVal)
Set reg1 = New RegExp
reg1.Gloabl=True
reg1.IgnoreCase=False
reg1.Pattern="\d+"
Set mats = reg.Execute(StrVal)
For Each mat In mats
  return mat.Value
Next
End Function

And then passing the value returned in another string

StrNum = IsHaving(StrVal)

I would like to do this way but i am not sure that in vb i can return from a loop for ( within the Function). Some ideas on that ?

0

There are 0 best solutions below