Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Visual Basic > VB.NET 1.0 > VB.NET 2002/2003 Basics
Password Reminder
Register
| FAQ | Members List | Search | Today's Posts | Mark Forums Read
VB.NET 2002/2003 Basics For coders who are new to Visual Basic, working in .NET versions 2002 or 2003 (1.0 and 1.1).
Welcome to the p2p.wrox.com Forums.

You are currently viewing the VB.NET 2002/2003 Basics section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old March 7th, 2005, 03:15 PM
Authorized User
 
Join Date: Aug 2004
Location: OKC, OK, USA.
Posts: 17
Thanks: 0
Thanked 0 Times in 0 Posts
Default Editing text in a richtextbox

I have created a program that opens a text file into a RichTextBox1. Now that I have this accomplished I would like to go through the list of text and clean it up. What I have is a list of stats for various people who play an online game. The problem is that there is also stats that are embedded for computer generated players. These are identified throughout the text as having [BOT] at the end of the screen name. Each line of text contains the screen name and their stats. How can I go through the text in the RichTextBox1 and search for [BOT] and remove this line of text?



Jeff Armstrong
Sr. Systems Mgr
SBC Services, Inc.
__________________
Jeff Armstrong
Sr. Systems Mgr
SBC Services, Inc.
Reply With Quote
  #2 (permalink)  
Old March 7th, 2005, 04:01 PM
Friend of Wrox
 
Join Date: Nov 2004
Location: Port Orchard, WA, USA.
Posts: 1,621
Thanks: 1
Thanked 3 Times in 3 Posts
Default

Put the contents of the textbox into a string, manipulate the string, then replace the box’s contents with the contents of the manipulated string.

You are going to have to create a routine that knows how to “read” (so to speak).
Reply With Quote
  #3 (permalink)  
Old March 7th, 2005, 05:16 PM
Authorized User
 
Join Date: Aug 2004
Location: OKC, OK, USA.
Posts: 17
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I guess all I really need at this point is to search for [BOT] within a string. If it has it then delete the string otherwise move on. Is there a way that I can search the string and so some type of compare?

Jeff Armstrong
Sr. Systems Mgr
SBC Services, Inc.
Reply With Quote
  #4 (permalink)  
Old March 7th, 2005, 05:52 PM
Friend of Wrox
 
Join Date: Nov 2004
Location: Port Orchard, WA, USA.
Posts: 1,621
Thanks: 1
Thanked 3 Times in 3 Posts
Default

You can use the .IndexOf("Pattern") method of a string to find the 1[u]st</u> occurence of a pattern within a string.
You can use .IndexOf("pattern", n) to find the next occurence of a pattern within a string, starting at character #n.

You can use .LastIndexOf("pattern") to find the last occurence of a pattern within a string.
(.LastIndexOf() can also accept a 2nd argument, just like IndexOf())
Reply With Quote
  #5 (permalink)  
Old March 8th, 2005, 05:15 PM
Authorized User
 
Join Date: Aug 2004
Location: OKC, OK, USA.
Posts: 17
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I got the filter to work. Thanks for the tip. I decided to go with a ListBox rather than a RichTextBox. It was easier to implement in real time and faster. My only problem now is saving the data within the ListBox. How can I save the data in the ListBox to a text file?

Jeff Armstrong
Sr. Systems Mgr
SBC Services, Inc.
Reply With Quote
  #6 (permalink)  
Old March 9th, 2005, 04:10 PM
Friend of Wrox
 
Join Date: Nov 2004
Location: Port Orchard, WA, USA.
Posts: 1,621
Thanks: 1
Thanked 3 Times in 3 Posts
Default

.NET has a variety of functions for streaming to a text file. (I believe they are in System.IO...)

Though (I believe) you can directly save the contents of a richtext box, you have to handle the file yourself with a listbox.

It is pretty easy though. You open a stream object having set it to append or replace, then one-line-at-a-time (with .WriteLine) or character-by-character (with .Write) put your data into the file, then close it.
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Selecting Text When Editing Datagrid elygp ASP.NET 1.0 and 1.1 Professional 1 May 29th, 2007 04:58 PM
Editing a Text File mh VB.NET 1 December 8th, 2005 02:37 AM
Deleting text from a RichTextBox wslyhbb C# 0 October 29th, 2005 08:00 PM
.NET Text / HTML editing problem clickco General .NET 3 May 12th, 2004 02:47 PM
#region text in RichTextBox? mfourre C# 1 August 7th, 2003 12:49 PM



All times are GMT -4. The time now is 03:34 PM.


Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.