|
-
Dec 2nd, 2006, 02:12 AM
#1
Thread Starter
Fanatic Member
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,
-
Dec 2nd, 2006, 02:15 AM
#2
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.
-
Dec 2nd, 2006, 02:35 AM
#3
Thread Starter
Fanatic Member
Re: correct text format
@ganeshmoorthy
yes.. but the name and address sometimes the length is not the same..
do you have any sample?
-
Dec 2nd, 2006, 02:38 AM
#4
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
-
Dec 2nd, 2006, 03:26 AM
#5
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.
-
Dec 2nd, 2006, 05:15 AM
#6
Thread Starter
Fanatic Member
Re: correct text format
@ganeshmoorthy
hi, i really cant do it do you have samples?
regards,
-
Dec 2nd, 2006, 10:53 PM
#7
Thread Starter
Fanatic Member
Re: correct text format
anyone could make a sample?
regards,
-
Dec 2nd, 2006, 11:30 PM
#8
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:
Dim strInfo() As String
strInfo() = Split(Info, "|")
'This is what you would get:
'strInfo(0) = ALERT
'strInfo(1) = Nokia 6630
'strInfo(2) = 123456789012347
'strInfo(3) = Edmund Cinco
'etc...
-
Dec 3rd, 2006, 12:01 PM
#9
Hyperactive Member
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|