|
Hi Professionals, I am using Microsoft Visual Studio 2005. I would like to know how to separate content in a richtextbox(rtbTo) in windows form with a comma automatically. For example after copying email addresses from a .txt file and pasting it to the richtextbox(rtbTo), there should be a comma inserted automatically, seperating each email address. I tried to find such settings in the properties of the richtextbox but is unsuccessful. Any help or advice will be appreciated. Best Regards, Md Azmil
|
| Md Azmil Friday, July 24, 2009 3:34 AM |
Try the following Code:
Dim SRead As StreamReader
Dim Email As String = ""
SRead = New StreamReader("C:\myfile.txt")
rtbTo.Text = ""
'Read the First Line
Email= SRead.ReadLine
'Continue to read until you reach the end of the file.
Do While Not Email Is Nothing
rtbTo.Text &= ","
'Read the next line.
Email = SRead.ReadLine
Loop
SRead.Close()
I have assumed that the email addresses are separated by a carraige return.. You can use whatever your logic is..
Ashray Lavsi
If my post answers your Question, don't forget to "Mark it as Answer" - Marked As Answer byMd Azmil Monday, July 27, 2009 8:17 AM
-
|
| Ashray Lavsi Friday, July 24, 2009 7:54 PM |
Hi Md Azmil, Welcome to MSDN again. Based on my understanding, you want to add a comma at the end of each email address so they can be separated from each other. RichTextBox control cannot do that for you. You want to load the text from a .txt file. What is the format of the text in that txt file? Does each line contains only one email address? If so, I think the code given by Ashray Lavsi is the correct one to accomplish that task. If that cannot meet your need, please feel free to tell me. Sincerely, Kira Qian Please mark the replies as answers if they help and unmark if they don't.- Marked As Answer byMd Azmil Monday, July 27, 2009 8:17 AM
-
|
| Kira Qian Monday, July 27, 2009 8:14 AM |
I think you have to write your own logic for that. -@SuDhiR@- |
| _SuDhiR_ Friday, July 24, 2009 4:38 AM |
You mean there isn't any functions to automatically add a comma in richtextbox? |
| Md Azmil Friday, July 24, 2009 6:04 AM |
Try the following Code:
Dim SRead As StreamReader
Dim Email As String = ""
SRead = New StreamReader("C:\myfile.txt")
rtbTo.Text = ""
'Read the First Line
Email= SRead.ReadLine
'Continue to read until you reach the end of the file.
Do While Not Email Is Nothing
rtbTo.Text &= ","
'Read the next line.
Email = SRead.ReadLine
Loop
SRead.Close()
I have assumed that the email addresses are separated by a carraige return.. You can use whatever your logic is..
Ashray Lavsi
If my post answers your Question, don't forget to "Mark it as Answer" - Marked As Answer byMd Azmil Monday, July 27, 2009 8:17 AM
-
|
| Ashray Lavsi Friday, July 24, 2009 7:54 PM |
Hi Md Azmil, Welcome to MSDN again. Based on my understanding, you want to add a comma at the end of each email address so they can be separated from each other. RichTextBox control cannot do that for you. You want to load the text from a .txt file. What is the format of the text in that txt file? Does each line contains only one email address? If so, I think the code given by Ashray Lavsi is the correct one to accomplish that task. If that cannot meet your need, please feel free to tell me. Sincerely, Kira Qian Please mark the replies as answers if they help and unmark if they don't.- Marked As Answer byMd Azmil Monday, July 27, 2009 8:17 AM
-
|
| Kira Qian Monday, July 27, 2009 8:14 AM |
The codes Ashray Lavsi posted worked great. Thank you Ashray Lavsi and Kira Qian.
|
| Md Azmil Monday, July 27, 2009 8:19 AM |