Remove garbage from text in Combobox
Remove garbage from text in Combobox
Remove garbage from text in Combobox
Remove garbage from text in Combobox
Remove garbage from text in Combobox
Remove garbage from text in Combobox Remove garbage from text in Combobox Remove garbage from text in Combobox Remove garbage from text in Combobox Remove garbage from text in Combobox Remove garbage from text in Combobox Remove garbage from text in Combobox Remove garbage from text in Combobox
Remove garbage from text in Combobox Remove garbage from text in Combobox
Remove garbage from text in Combobox
Go Back  Xtreme Visual Basic Talk > > > Remove garbage from text in Combobox


Reply
 
Thread Tools Display Modes
  #1  
Old 01-31-2004, 05:27 PM
VBMarkO VBMarkO is offline
Contributor
 
Join Date: Dec 2003
Posts: 398
Default Remove garbage from text in Combobox


I need to remove the Quotation and commas from the names I saved in a sequential file

I am getting on input to the combobox this;

"John Smith","Smith"

I want;

John Smith

This is the code I am using

Code:
Dim strFirstName As String Dim strLastName As String Dim strPlayerName As String Dim FileNum As Integer FileNum = FreeFile strPlayerName = strFirstName & " " & strLastName Open App.Path & "\ScoutPlayers.txt" For Input As #FileNum Do While Not EOF(FileNum) Line Input #FileNum, strPlayerName cmbPlayers.AddItem strPlayerName Loop Close #FileNum

Help please
vbMarkO
Reply With Quote
  #2  
Old 01-31-2004, 05:42 PM
MikeJ's Avatar
MikeJRemove garbage from text in Combobox MikeJ is offline
Retread

Retired Moderator
* Expert *
 
Join Date: Sep 2002
Location: Austin, Texas
Posts: 6,747
Default

Seeing as this looks like VB6 syntax, and not .Net (where you posted), I'll give you the VB6 answer.

If you are getting it that exact way from your file, then I'd recommend doing this before adding to the combobox:
Code:
Dim strFirstName As String Dim strLastName As String Dim strPlayerName As String Dim FileNum As Integer FileNum = FreeFile strPlayerName = strFirstName & " " & strLastName Open App.Path & "\ScoutPlayers.txt" For Input As #FileNum Do While Not EOF(FileNum) Line Input #FileNum, strPlayerName 'Replace lines strPlayerName = Replace(strPlayerName, Chr(34) & "," & Chr(34), " ") strPlayerName = Replace(strPlayerName, Chr(34), "") 'Add to the combobox cmbPlayers.AddItem strPlayerName Loop Close #FileNum
__________________
{ Lex Fori } { Locus Classicus } { Rutilus Scrinium }
Osculare pultem meam!
Reply With Quote
  #3  
Old 01-31-2004, 07:47 PM
VBMarkO VBMarkO is offline
Contributor
 
Join Date: Dec 2003
Posts: 398
Default

Quote:
Originally Posted by MikeJ
Seeing as this looks like VB6 syntax, and not .Net (where you posted), I'll give you the VB6 answer.

If you are getting it that exact way from your file, then I'd recommend doing this before adding to the combobox:
Code:
Dim strFirstName As String Dim strLastName As String Dim strPlayerName As String Dim FileNum As Integer FileNum = FreeFile strPlayerName = strFirstName & " " & strLastName Open App.Path & "\ScoutPlayers.txt" For Input As #FileNum Do While Not EOF(FileNum) Line Input #FileNum, strPlayerName 'Replace lines strPlayerName = Replace(strPlayerName, Chr(34) & "," & Chr(34), " ") strPlayerName = Replace(strPlayerName, Chr(34), "") 'Add to the combobox cmbPlayers.AddItem strPlayerName Loop Close #FileNum



Love it, did the trick.. Now if its ok let me ask you questions about what happend here.

You added to my code this Chr(34) & "," & Chr
What is "Chr" and "Chr(34)"???
I think I understand what is happening with the next but feel to correct me if I am off here...

when you did strPlayerName = Replace(strPlayerName, Chr(34) $ "," & Chr
You are telling it to replace or remove the "<Comma>"
the next live removes ""

Thus we would not have "John","Smith" Correct?

I guess I dont understnad what Chr and Chr(34) stand for

But thank you for the help just want to learn from you guys too if thats ok instead of getting some help and running with it


vbMarkO
Reply With Quote
  #4  
Old 01-31-2004, 11:03 PM
MikeJ's Avatar
MikeJRemove garbage from text in Combobox MikeJ is offline
Retread

Retired Moderator
* Expert *
 
Join Date: Sep 2002
Location: Austin, Texas
Posts: 6,747
Default

Chr is a function, which returns the ASCII character of the number inside of it. So, Chr(34), would return a quotation mark. Asc is the opposite of Chr, so Asc(""") would return 34.
__________________
{ Lex Fori } { Locus Classicus } { Rutilus Scrinium }
Osculare pultem meam!
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
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

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
ComboBox text not settable jesseman General 2 12-05-2003 06:59 AM
Bullettin problem pckm_123 Word, PowerPoint, Outlook, and Other Office Products 1 12-03-2003 06:59 AM
Logging keys to edit text Wise_Reeper General 5 12-09-2002 08:01 PM
Wraping text around an image? Serevinus Web Programming 7 06-20-2002 01:46 PM
Combo makes RTB`s visible? golash General 2 11-27-2000 02:16 PM

Advertisement:





Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe
Remove garbage from text in Combobox
Remove garbage from text in Combobox
Remove garbage from text in Combobox Remove garbage from text in Combobox
Remove garbage from text in Combobox
Remove garbage from text in Combobox
Remove garbage from text in Combobox Remove garbage from text in Combobox Remove garbage from text in Combobox Remove garbage from text in Combobox Remove garbage from text in Combobox Remove garbage from text in Combobox Remove garbage from text in Combobox
Remove garbage from text in Combobox
Remove garbage from text in Combobox
 
Remove garbage from text in Combobox
Remove garbage from text in Combobox
 
-->