I have a form in which I need to sort text from the clipboard into the appropriate fields. Essentially, I copy a customer email, click a button on the form, and it will read the data and put the info into the fields. There are several fields, such as the customer's name, the company's name, the telephone number, whether they have a support plan.
All emails are formatted in the same way (apart from the random spaces which I have no control of) and are used by several employees:
Company: TEST LTD
Customer's name: Joe Johnson
Department: IT Operations Manager
Customer's phone: 012345678910
Customer's email: [email protected]
Instrument: SUP
Serial Number: EM2PC2938C
Coverage: Plan No Warranty
So, my question is:
I need to be able to copy this text straight from an email, click on a button that will look through the text in the clipboard, and put the different pieces of information into different text boxes labelled the same as in the email, but without the identifier (such as 'Email:' or 'Coverage'), so essentially anything after the colon goes into the textbox.
I have some code to get the data and put into into a rich text box which I planned to use to sort the data (I know I can do it straight from code, but didn't know how to)
rtbx_ClipboardData.text = Clipboard.GetText
And some code to remove any text before the colon:
tbx_Data_Company.Text = rtbx_ClipboardData.Text.Substring(rtbx_ClipboardData.Text.IndexOf(":") + 1)
This code works but I need to do it several times and put data into the appropriate fields which is where I am struggling.
If anyone could suggest anything/provide some sample code I'd greatly appreciate it.
See Question&Answers more detail:
os