Find&Replace multiple words in userform TextBox
Hello.
I have been trying to find some solution or workaround to this, but surprisingly (and annoyingly) it doesn't seem like anything I've found online can be used for my situation.
I have a userform where there is a TextBox, let's say "TextBox01". In it, the user would input a series of numbers, and each number would always refer to certain words. For example, number "01" would refer to "broken left arm", "02" would refer to "broken right arm", and so on. With plenty of bones to break, the list is quite long, sitting at about 50 possible numbers, each of which would have to be then "converted" (via find-and-replace or any similar method) into words.
The "converted" (replaced) text would then appear into TextBox02, and then further processed to eventually be inserted into a bookmark, Bookmark01.
I initially had success using this formula into TextBox01:
Me.TextBox02 = Replace(Me.TextBox01, "01", "broken left arm")
I was baffled to find out that one of these is just about all the program can handle. If I place two of them, only the second one will be applied (only the second number will be found-and-replaced); if I place three or more the program will crash as soon as I type the third number.
Anyway, I've searched on google for hours and found lots of similar cases, but never one where they do this exact thing. Sometimes the code is for Excel (like, 80% of the time), sometimes it's for the whole document, sometimes it's for TextBoxes in the document but not for TextBoxes in the userform, ... "Frustrating" doesn't even begin to describe my experience with it, as this seems like an extremely simple thing to do, and yet it seems there is no easy function where you can just make a list of all the replacements you need. The way the program crashed was particularly infuriating, as I'm sure something as simple as finding and replacing text cannot require so much "power" that three requests at once would blow up a whole code. Before this I had tried writing a few hundreds of "if -> then" statements to manually replace the text that way, and THAT worked instantly without a hiccup. Like the infomercials say though, there has to be a better way.
|