Prove position of quotation mark at beginning of string

  • Thread starter Thread starter Ed Bitzer
  • Start date Start date
E

Ed Bitzer

How to I assure myself that there is a quotation mark at the beginning
of a field (an imported csv file with commas embedded in column one,
i.e. "Bitzer, Ed")? I have read the field into an array in my program
(field(x)) and the leading quotation mark is definitely there.
dim x as integer
dim s as string
If I try x = field(x).indexof(chr(34),0,1), x = -1
If I try s = field(x).substring(0.1)) r = B
No problem picking up the second quotation mark indicated to be at
position 10.

Ed
 
In your 'indexof' test you will need to use ChrW(34) instead of Chr(34).

I would use:

If field(x).StartsWith("""") AndAlso field(x).EndsWith("""") Then
...
End If

to test if they are both there.
 
Stephany,

Thanks so much. Both IndexOf(ChrW(34)) and StartsWith("""") work as
you realized - but not me<g>. I probably spent three hours trying to
figure out why I was making no progress. Fortunately I am retired
(well not really, the age is there too<g>) and there is no pressure.
Not working in the trade (actually never did, just on the edge) my
only source of help are books (Michael Halvorson's does not even
mention ChrW), the Microsoft help files which are major confusion to
an amateur, and this forum. I do appreciate every one of you. I
promised to do my homework and determine why these syntax work. With
your earlier help and this, I have fairly nice email software program
written to send our almost daily announcements to our 200 plus
residence in smaller batches to comply with our ISP's restrictions.

Ed

I am stilling fighting from by community association for which I am
programming for fun
 
Stephany Young said:
In your 'indexof' test you will need to use ChrW(34) instead of Chr(34).

I would use:

If field(x).StartsWith("""") AndAlso field(x).EndsWith("""") Then

I would use 'ControlChars.Quote' ;-) Note that '""""' is a string
containing a quotation mark whereas '""""c' is a 'Char' literal.
 
Back
Top