[RESOLVED] The Separator Character Code
Hi, I'm asking to see if anybody knows of a separating character code. This is because of the task of saving strings. If you use vb's input output file methods you have a problem with these things >>> " <<< You can't use tab because that's a usefull thing to use inside strings and you can't use split and join with commas because you can enter a comma into a textbox. Basically i'm looking for a character code which means absolutely nothing except "separator". In my program in each line i'm saving a description(which is a string) and then some numbers behind that. At the moment i'm using split and join with "*`*" but that isn't a solution because anybody could enter that into a textbox. Hopefully someone knows of such a thing.
Re: The Separator Character Code
There are several characters one cannot easily enter into a textbox, here are two:
Quote:
Back (vbBack or Chr$(8))
Null (vbNullChar or Chr$(0))
Edited: Suggestion. Whatever value you choose, you may want to validate the textbox before accepting the entry. If the textbox contains the character you plan on using for a separator then warn user an invalid character exists or replace it out.
Other characters to consider may be from the range of 0-11 (except tab of course). However, some of these have special meaning for file input/output and should not be used in my opinion. May be good idea to look at an ASCII table to know what characters 0-11 traditionally were intended for. How could someone enter non-keyboard characters? Paste and using the ALT+keypad method are ways
Re: The Separator Character Code
Okay, so Chr(0) could never be entered into a textbox? That looks like the ideal thing to use.
Re: The Separator Character Code
Re: double quotes in user data enty
Better than disallowing user entry of double quotes. Convert/ Replace them when read by the app with single quotes.
Re: The Separator Character Code
I don't think that i'd like to turn what they put in into something else. I know how to save text to a file preserving quotes, but that would require printing to a single line. The reason why i'd like a seperator character is so that i can put the text on a line with other numbers.
Re: The Separator Character Code
if you put chr(0) into the textbox characters after will not be displayed
variables can contain chr(0), but not controls
Re: The Separator Character Code
Quote:
Originally Posted by
westconn1
if you put chr(0) into the textbox characters after will not be displayed
variables can contain chr(0), but not controls
I used to use Chr$(1) or Chr$(2) for delimiters and identifiers. That worked much better than Chr$(0).
Nice to see we are wandering backwards into the '80s and '90s again. :bigyello:
Re: The Separator Character Code
You can also use vbVerticalTab and vbFormFeed. Any of the named constants will be more efficient than the slow Chr$() or slower Chr() functions.
But using any control character as a field delimiter suggests the resulting file (if indeed a file is the goal here) doesn't need hand editing by users. In that case there are many alternatives that will either be faster, more flexible, or both. Splits and concatenations tend to be pretty slow and clunky.
You could use UDTs and record I/O, Jet MDBs, Jet's Text IISAM (which can handle escaping quotes for you), dBase/FoxPro "free tables" via Jet's IISAMs or a VFP Provider, persisted ADO Recordsets, PropertyBags, ... the list ges on and on.
Re: The Separator Character Code
Thanks for all the help and suggestions. I had though that there might be characters which can never be produced by a textbox and i'm glad to know the ones which are.
Re: [RESOLVED] The Separator Character Code
having done way too much in the textfile world, you might come a cropper with the apostrophy it was an old dos separator error...
We had to change a whole lot of place names in a datset once because the fields where separating whenever the appostrophy cropped up!
st.John~s in stead of st.john's was the fix at the time.