[2008] Making TextFieldParser work with quotation marks -
Hi Guys,
I'm using the following code to read some values in from a tab delimited text file:
vb.net Code:
Using Parser As FileIO.TextFieldParser = My.Computer.FileSystem.OpenTextFieldParser(LogFile, vbTab)
Parser.TextFieldType = FileIO.FieldType.Delimited
Dim comments(0) As String
comments(0) = "#"
Parser.CommentTokens = comments
Parser.HasFieldsEnclosedInQuotes = True
While Not Parser.EndOfData
Try
Dim CurrentFields As String() = Parser.ReadFields
If CurrentFields.Length > 0 Then
'Do stuff here
End If
Catch ex As Exception
MessageBox.Show(ex.Message)
End Try
End While
End Using
This works fine for the most part but with some files I get an error stating that some line numbers could not be read. I found the corresponding lines in the text files and it seems that this error occurrs only when there is a string that contains quotation marks in it. This is one example of a problematic line (yes this is to do with spam emails):
Code:
2009-1-8 17:58:33 GMT - "Are you unlucky in finding a perfect wife?" you have 6 unread messages from ladies newsboydh87@bbacks.com -
As you can see I have set the HasFieldsEnclosedInQuotes property to true on the textfieldparser because I want to make sure I capture the data correctly if quotation marks are used. If I set the HasFieldsEnclosedInQuotes property to False then it all works (or at least it doesnt error anyway) but like I said, I need to have that set to true because otherwise if the line contained a tab character within the quote marks then my app would think this was two separate fields and process it incorrectly...
Any suggestions?
Cheers
Chris
INSERT INTO quotation marks problems -
I'm using sql over vb/vba and trying to insert into my database a string that might contain " ' and/or space chars.
here's an example for a statement:
sql = "INSERT INTO tbl1( field1 ) SELECT """ & myFreeText & """ AS Exp1 ;"
How to Remove Quotation Marks -
I was wondering when I write strings to files how can I make the quotation marks not appear in the file, for example if I write a string to a file names z.txt and open it up it will have quotation marks before the text and after, so how can I remove this in visual basic when I write a
Writing quotation marks -
Well, its a very simple question, but extremely important. I need to know how you write in quotation marks for stuff, given the fact that quotes are used for distinguishing text. Everything I try results in the quote marks ending the text, and anything I type after that is shown as jus
Removing quotation marks..how -
Hi!
I was thinking about : how to remove quotation marks from the following string using VB :
"sdfsdfsdfsd"
I want to remove the first quotation and the last one..
Thanks in advance!
display quotation marks in form -
i want a form to display HTML with sets of quotation marks (")
it won't work otherwise, is there a way around it?
thanks in advance
Quotation marks are a pain is the azz. -
At least I think they are. I found out that if you want a variable to be a double quotation mark then you have to do X = """" which doesn't make much sense but anyway. I've got a file that has nothing but a double quotation mark in it. I open the file for input as #
problem with quotation marks in outputting files -
using simple code that outputs to a text file leaves me with the text i wanted in quatation marks, is there any way to remove them?
say i had:
arr$ = "hello"
Open "arr.txt" For Output As #1
Write #1, arr
Close #1
when i open arr.txt it will say:
"h
Sequential File quotation marks -
Could someone of high intelligence please tell me if it's possible, and if it is, how you can write a sequential file so if you open it up in note pad, etc, and there aren't quotation marks around everything.
I only want the text, no formatting, just what I want to be there.
Con
Quick Question about Quotes -
How do I put Quotation Marks In A Textbox?
textbox1.text = ""Quotation Marks Are Tricky In VB," said the man"
That would give an error.
What's the difference between.... -
Suppose I use a textbox to add items into a listbox, and in the code I have this:
Open c:\blahblahblah
Write ..............
close ...........
If I use Write, the item in the listbox would show with quotation marks...for example, I added the word Apple in the listbox, it would app
How do i escape out of quotation marks -
Hi
I want to escape out of "" quotation marks so that I can put quotation marks in normal text specifically ...
I want to create a line of text inside a cell which looks like this
/label="exon predicted with cDNA"
The problem is that w
NOT storing chr(34) in files -
I am storing a string with a double quote in it, so in the code I use chr(34)
temp= "a" & chr(34)
but when I write this to a file it stores as "a"""
Anyone know how I could stop this, I think if there was a way to store the whole string withou
Easy String Question -
Hello
Just enquiring about how you would remove the first and last character from a string.
I used the split command to put fields from csv file into array but the problem is that each array item have quotation marks around them.
eg array(0) has value of ""AAAA"&quo
Parsing Single and Double Quotes... -
Hi folks, first post here and hope you can help.
The following command is bombing because VB can't parse the double quotation marks within double quotation marks. I've tried changing the quotation marks to single quotes and that works fine for some records that are processed but whe
Using insert SQL -
there is some syntax error in my code when I use insert SQL with text box
Its due to those damned quotation marks.
I am not doing any mistake in query however when I use input from text its showing error I have forgot where and when to place the quotation marks
rs.Open("Ins
two15two@hotmail.com -
I'm creating a program that will do MLA formatting. As such I have to be a little picky about the details and I would really hate to scrap the whole project over this, anyway, here's my problem. In order to put quotation marks into a string you have to put two of the (like so "&
Quotation marks problem -
Hello. I have this problem. I am programming this email program that uses the command line and visual basic scripts. When i try to put this command in my code shell "echo Set OutlookApp = CreateObject("Outlook.Application")>file.vbs" then i get error saying expec
Removing quotes from file -
How:
1) Can I remove the quotation marks from my strings before I write them to a .txt file.
ex. Write #file, strName, strValue
2) Or, how do I, after I write my text to the .txt file, remove the quotation marks from the .txt file.
3) Or, or, when I write out the info
[2005] Using a scrollbar to set form opacity. -
Hi. How can I use a scrollbar to set form opacity?
I tried 'Me.Opacity = (VScrollBar1.Value)' and this only works with 1 and 100.
I also tried 'Me.Opacity = (VScrollBar1.Value) & "%"', and it tells me I can't convert a string to a double, because of the quotation ma
[2008] Making TextFieldParser work with quotation marks -
Hi Guys,
I'm using the following code to read some values in from a tab delimited text file:
vb.net Code:
Using Parser As FileIO.TextFieldParser = My.Computer.FileSystem.OpenTextFieldParser(LogFile, vbTab)
HTML Tag Coloring, anyone -
Hey guys and gals -
I am working with an RTFText Box, and I need to make tag coloring for HTML elements such as: carrots (<, and >), equal signs with quotation marks (=""), and text that's in between the quotation marks (="text"). If anyone can help me out
Urgent!!! Quotation marks within quotation marks -
Can someone please tell me how to get around using quotes inside of a string e.g.
RemapCode$ = RemapCode$ & " <bind action = "use_item" key1 = "key_mouse1" key2 = ""/> "
I don't have the option of removing the quotes inside the s
Interdev BUG -
has anyone had experience with Interdev out of nowhere start corrupting asp files and making some quotation marks into the asci equivalent?
Write command and " " marks -
Should be simple.
I was trying to write a code that would write some code for me, just to save time. What it was doing was looking for duplicate
strings in an array and assigning values to the array as needed.
Not too relevant.
Basically, I want my code to do this:
Write #
quoation marks in a string -
I have just started using VB.NET and am trying to use quotation marks inside a string. How do I make it so that VB doesn't think I am tring to end a string?
Shell, No QUOTATION Marks!! Stupid.... -
I'm trying to send a command line to a program from a shell command,
the command line is: bplay.exe "movie.avi" [-FS]
In vb its a little hard due to there being quotation marks,
I've tryed this and program just can't find the file,
please!! help me correct this syntax:
Quotation marks with WRITE statement -
Another Quick Question:
When I write to an external file using the write statement, it always puts quotation marks at the beginning and end of the string... is something wrong with my code??
Example:
NameOfPerson = "John Jacob Jingleheimer Smith"
Write #1, NameOfPe
Access Reserved Characters -
I'm developing an ASP.NET application using an Access 2002 database as the backend. I've been told that you should replace the following characters (quotation mark " and single quote ') with two quotation marks ("") or two single quotes ('') when adding strings to the d
Write #Fhandle Problem -
I'm trying to make a program that will save whatever text you enter in a text boc to "c:\random.txt" but I Can't seem to get it to work, if it does work it put's Quotation marks around the text and I don't want that... Can anyone help?
Receiving quotation marks from a .CSV file -
I'm getting some weird input in my VB.Net 2005 program. I am reading a .CSV file as input and parsing the fields. When I look at the raw file, there are no quotation marks in the file, however, when I parse an Address field, it places quotation marks around the value and I'm not sure w
What's the easiest way to display quotation marks -
Hello, I'm Captain Beginner in that I have no idea what I'm doing.
I was trying to put together a little program and part of it required adding quotation marks to something and then displaying that in a text field.
This is an example of how I've been doing it, but I have a feeling
Saving & Retrieving Quotes " (chr(34)) -
Can someone tell me how to save quotation marks around my text string and retrieve them when the file is re-opened?
This would be a text file, with " " as the delimiter.
e.g., How to save:
" "Programmer's quotation sub-routine" "
so that when
Help Needed!!! Class Marks Calculator -
I've got a problem and i hope someone can save me!!! Could anybody tell me how to write a code for calculating the average marks for a class? This is my assignment question. It says that i need to create to calculate the average marks for a class. the application first gets the number
Retrieve a string from a text file. -
Hello all,
I would like to know how I could search a text file for a string and only get the contents between a set of quotation marks and copy only those values to another text file.
For example:
In the text file, you might have this:
name="some text or numbers"
Printing Scripts in a plain textbox -
I am making a script archive program in VB that has menus for JavaScript, VBScript, DHTML, Etc... When you click a specific script, it writes it in a plain text box. But it errors when it reads, for example, the "}" character in a JScript. I used - Const QUOTE = ""&
char -
i am trying to replace anywhere there is a " in a string with a space.
Basically i ant to remove all "s in the string however when i do
replace(string,""","") it throws an error because there are three quotation marks.
i was thinking mayb i coul
Adding quotation Marks around a string -
How Do you add quotation Marks around a string?
Example:
VB Code:
Winsock1.Send strMessage
How can I put strMessage in quotations?
Z-Score Of a marks list -
I want to get the z-Score for each record of a Marks List.
Z-Score = ([Student Marks]-[average Of Subject Marks])/([standard Deviation Of marks list])
In Excel command
=(A1-Avg(A$1:A$50))/STDev(A$1:A$50)
Note: "A1"-current student marks
"A$1:A$50"-Marks List
Write # function -
how do i write data to a simple text file without having the quotation marks around each line
Parsing witespace -
Hey ho.
Is it possible to split a string by spaces, but ignore spaces inside quotation marks? (")
Thanx very much!