|
-
Dec 16th, 2011, 08:37 AM
#1
Thread Starter
Addicted Member
[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.
-
Dec 16th, 2011, 09:29 AM
#2
Re: The Separator Character Code
There are several characters one cannot easily enter into a textbox, here are two:
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
Last edited by LaVolpe; Dec 16th, 2011 at 10:09 AM.
-
Dec 16th, 2011, 01:29 PM
#3
Thread Starter
Addicted Member
Re: The Separator Character Code
Okay, so Chr(0) could never be entered into a textbox? That looks like the ideal thing to use.
-
Dec 16th, 2011, 03:12 PM
#4
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.
-
Dec 17th, 2011, 01:50 AM
#5
Thread Starter
Addicted Member
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.
-
Dec 17th, 2011, 07:36 PM
#6
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
i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next
dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part
come back and mark your original post as resolved if your problem is fixed
pete
-
Dec 17th, 2011, 08:59 PM
#7
Re: The Separator Character Code
 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.
-
Dec 18th, 2011, 06:22 AM
#8
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.
-
Dec 18th, 2011, 07:50 AM
#9
Thread Starter
Addicted Member
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.
-
Dec 18th, 2011, 05:01 PM
#10
Frenzied Member
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.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|