Results 1 to 10 of 10

Thread: [RESOLVED] The Separator Character Code

  1. #1

    Thread Starter
    Addicted Member cheesebrother's Avatar
    Join Date
    Jul 2011
    Posts
    153

    Resolved [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.
    Hooked for good.

  2. #2
    VB-aholic & Lovin' It LaVolpe's Avatar
    Join Date
    Oct 2007
    Location
    Beside Waldo
    Posts
    19,541

    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.
    Insomnia is just a byproduct of, "It can't be done"

    Classics Enthusiast? Here's my 1969 Mustang Mach I Fastback. Her sister '67 Coupe has been adopted

    Newbie? Novice? Bored? Spend a few minutes browsing the FAQ section of the forum.
    Read the HitchHiker's Guide to Getting Help on the Forums.
    Here is the list of TAGs you can use to format your posts
    Here are VB6 Help Files online


    {Alpha Image Control} {Memory Leak FAQ} {Unicode Open/Save Dialog} {Resource Image Viewer/Extractor}
    {VB and DPI Tutorial} {Manifest Creator} {UserControl Button Template} {stdPicture Render Usage}

  3. #3

    Thread Starter
    Addicted Member cheesebrother's Avatar
    Join Date
    Jul 2011
    Posts
    153

    Re: The Separator Character Code

    Okay, so Chr(0) could never be entered into a textbox? That looks like the ideal thing to use.
    Hooked for good.

  4. #4
    Frenzied Member
    Join Date
    Mar 2008
    Posts
    1,210

    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.

  5. #5

    Thread Starter
    Addicted Member cheesebrother's Avatar
    Join Date
    Jul 2011
    Posts
    153

    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.
    Hooked for good.

  6. #6
    PowerPoster
    Join Date
    Dec 2004
    Posts
    25,618

    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

  7. #7
    PowerPoster Code Doc's Avatar
    Join Date
    Mar 2007
    Location
    Omaha, Nebraska
    Posts
    2,354

    Re: The Separator Character Code

    Quote Originally Posted by westconn1 View Post
    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.
    Doctor Ed

  8. #8
    PowerPoster dilettante's Avatar
    Join Date
    Feb 2006
    Posts
    24,487

    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.

  9. #9

    Thread Starter
    Addicted Member cheesebrother's Avatar
    Join Date
    Jul 2011
    Posts
    153

    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.
    Hooked for good.

  10. #10
    Frenzied Member
    Join Date
    Nov 2010
    Posts
    1,470

    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
  •  



Click Here to Expand Forum to Full Width