Results 1 to 9 of 9

Thread: correct text format

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Nov 2002
    Location
    Philippines
    Posts
    877

    correct text format

    hi, i have a project now about correct text format validating i tried creating but i get no luck someone could provide a simple code?

    the format should be:

    ALERT Brand/Model IMEI Name Address Cellphone Number Date Lost Place where it lost
    this is the text format:

    ALERT Nokia 6630 123456789012347 Edmund Cinco Catbalogan, Samar 09155618198 12-01-06 Divisoria, Manila
    if the format are now followed give error..

    Regards,

  2. #2
    VB Guru ganeshmoorthy's Avatar
    Join Date
    Dec 2005
    Location
    Sharjah, United Arab Emirates
    Posts
    3,031

    Re: correct text format

    why dont you use some delimiter to separate the values so that you can easily distinguish between the values and validate those...
    If an answer to your question has been helpful, then please, Rate it!

    Have done Projects in Access and Member management systems using BioMetric devices, Smart cards and BarCodes.


  3. #3

    Thread Starter
    Fanatic Member
    Join Date
    Nov 2002
    Location
    Philippines
    Posts
    877

    Re: correct text format

    @ganeshmoorthy

    yes.. but the name and address sometimes the length is not the same..

    do you have any sample?

  4. #4
    PowerPoster techgnome's Avatar
    Join Date
    May 2002
    Posts
    34,687

    Re: correct text format

    yes|like this|use a delimiter|and it doesn't matter|how long the values are in between|you'll still be able|to|tell when one ends|and the next one|starts.

    =tg
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

  5. #5
    VB Guru ganeshmoorthy's Avatar
    Join Date
    Dec 2005
    Location
    Sharjah, United Arab Emirates
    Posts
    3,031

    Re: correct text format

    If you have the delimiter then you can split the string into an array, so that the elements can be compared very easily...
    Last edited by ganeshmoorthy; Dec 2nd, 2006 at 04:06 AM.
    If an answer to your question has been helpful, then please, Rate it!

    Have done Projects in Access and Member management systems using BioMetric devices, Smart cards and BarCodes.


  6. #6

    Thread Starter
    Fanatic Member
    Join Date
    Nov 2002
    Location
    Philippines
    Posts
    877

    Re: correct text format

    @ganeshmoorthy

    hi, i really cant do it do you have samples?

    regards,

  7. #7

    Thread Starter
    Fanatic Member
    Join Date
    Nov 2002
    Location
    Philippines
    Posts
    877

    Re: correct text format

    anyone could make a sample?

    regards,

  8. #8
    "Digital Revolution"
    Join Date
    Mar 2005
    Posts
    4,471

    Re: correct text format

    You need to change the format of the text as the others have said. ie:

    this:

    Code:
    ALERT Nokia 6630 123456789012347 Edmund Cinco Catbalogan, Samar 09155618198 12-01-06 Divisoria, Manila
    becomes

    Code:
    ALERT|Nokia 6630|123456789012347|Edmund Cinco|Catbalogan, Samar|09155618198|12-01-06|Divisoria, Manila
    Now the program can know where one piece of information ends, and the next one begins. You can use the Split() function for this.

    VB Code:
    1. Dim strInfo() As String
    2.  
    3. strInfo() = Split(Info, "|")
    4.  
    5. 'This is what you would get:
    6. 'strInfo(0) = ALERT
    7. 'strInfo(1) = Nokia 6630
    8. 'strInfo(2) = 123456789012347
    9. 'strInfo(3) = Edmund Cinco
    10. 'etc...

  9. #9
    Hyperactive Member BrendanDavis's Avatar
    Join Date
    Oct 2006
    Location
    Florida
    Posts
    492

    Re: correct text format

    Use a delimiter & "split()" to get the items. Just make sure that if the items are saved to a file via a user's input, that you have some way of making sure that they cannot enter the delimiter into the text fields. Or have it change the delimiter in the text fields to something else, and change it back upon loading the saved file. That way your application will always get a valid item.

    For example:

    if you have the format like this: hi, my name is joe, i live in florida, i have a blue car


    ...You would use string = split(thefile, ",")(0) ...to find "hi", or string = split(thefile, ",")(1) to find "my name is joe", etc.

    But if you allow the user to type in a "," character into the text fields, it could frag the whole works. Because the line may look like this: hi, my name is joe, i live, in, florida, .... etc. So it won't read correctly.

    In that case, you could change the "," to "<comma>" in the text fileds, then save the file, and upon loading it again, change all instances of "<comma>" back to "," after you've loaded all the info.




    Just some tips on some things I've encountered ;D

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