Hi!
I have gotten so much help here! And I have come a long way programming VBA with all the help I get!
Now, in a thread from yesterday I learned a really nice way of using regex. I put that piece of code in a function in MODULE 1.
When i press a commandbutton I call that function along with several replace. But I cant get this function to return the string. It either makes the string "" and everything is lost, or nothing happens. How can I make the function return the modified value?
This code is located in MODULE 4
I have used the userform for storing information, but I really want to learn how to use return values, and get functions to return the values I need. I read the tutorials on microsoft...
But I can't even end the function by writing
It just ask me for a statement?
Hope anyone can help me make this big leap!
I have gotten so much help here! And I have come a long way programming VBA with all the help I get!
Now, in a thread from yesterday I learned a really nice way of using regex. I put that piece of code in a function in MODULE 1.
Code:
Public Function regexsolution(mystring As String)
'Dim mystring As String
Dim m As Variant
With CreateObject("VBScript.Regexp")
.IgnoreCase = True
.Global = True
.MultiLine = True
.Pattern = "(#datum)([1-9]+)(#)"
For Each m In .Execute(mystring)
nytext = Replace(mystring, m.Value, Format(Date + CInt(m.SubMatches(1)), "long Date"))
Next m
End With
End Function
When i press a commandbutton I call that function along with several replace. But I cant get this function to return the string. It either makes the string "" and everything is lost, or nothing happens. How can I make the function return the modified value?
This code is located in MODULE 4
Code:
Sub forhandsgranska(pages)
Dim nytext As String
Select Case pages
Case Is = 1
'**** RÄTT TEXTBOX****
nytext = UserForm1.TextBox100.Text
'******Here's the call to the function
call regexsolution(nytext)
'***also tried this code but i wont work
nytext = regexsolution(nytext)
nytext = Replace(nytext, "#datum#", Format(Date, "long Date"))
I have used the userform for storing information, but I really want to learn how to use return values, and get functions to return the values I need. I read the tutorials on microsoft...
But I can't even end the function by writing
Code:
return nytext
It just ask me for a statement?
Hope anyone can help me make this big leap!