Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Dec 31st, 2005, 10:49 AM   #1
office.boy
Newbie
 
Join Date: Dec 2005
Posts: 1
Rep Power: 0 office.boy is on a distinguished road
chr() split() etc..

Hi.

I'm fairly new to VB.

And i was wondering.

Could anyone help me with splitting?

See i don't know the concept of the functions chr() etc..

For example:

If fso.FileExists(App.Path & "\DATA\OBJDATA.TXT") = False Then Exit Function
roomdescs = fso.OpenTextFile(App.Path & "\DATA\OBJDATA.TXT", ForReading).ReadAll
roomfurniname = Split(roomdescs, finame & "_name = ")(1)
roomfurniname = Split(roomfurniname, Chr(13))(0)
roomdescription = Split(roomdescs, finame & "_desc = ")(1)
roomdescription = Split(roomdescription, Chr(13))(0)
thex = Split(SData, " ")(2)
they = Split(SData, " ")(3)

This laods from a text file etc..

Could anyone explain what is happening in this type of code and explain abit more about packet splitting and chr() Etc?

Thanks.
office.boy is offline   Reply With Quote
Old Jan 1st, 2006, 12:53 PM   #2
niteice
Programmer
 
niteice's Avatar
 
Join Date: Aug 2005
Posts: 98
Rep Power: 4 niteice is on a distinguished road
Send a message via AIM to niteice
Chr() returns a character code from the ASCII number given to it. 13 is the symbol for a new line, hence, you're splitting at every new line in that code.
niteice is offline   Reply With Quote
Old Jan 3rd, 2006, 5:03 PM   #3
Rory
Expert Programmer
 
Rory's Avatar
 
Join Date: Jan 2005
Location: London
Posts: 542
Rep Power: 4 Rory is on a distinguished road
Send a message via MSN to Rory
However that will leave trailing break Chr(10) characters on each item as on windows the new line sequence is actually CR LF - you should use the constant vbNewLine instead which is a platform dependent constant.
Rory is offline   Reply With Quote
Old Jan 3rd, 2006, 7:25 PM   #4
Ooble
I eat cake for breakfast.
 
Ooble's Avatar
 
Join Date: Jul 2004
Location: In my box.
Posts: 4,434
Rep Power: 9 Ooble is on a distinguished road
Because, y'know, VB is used on so many platforms...
__________________
Me :: You :: Them
Ooble is offline   Reply With Quote
Old Jan 4th, 2006, 2:15 PM   #5
Rory
Expert Programmer
 
Rory's Avatar
 
Join Date: Jan 2005
Location: London
Posts: 542
Rep Power: 4 Rory is on a distinguished road
Send a message via MSN to Rory
Mac is (barely) an operating system too. And I really meant .NET which runs on a multitude of architectures and platforms. Anyway it's better programming practice and more legible than a load of magic numbers.
Rory is offline   Reply With Quote
Old Jan 5th, 2006, 5:08 PM   #6
Ooble
I eat cake for breakfast.
 
Ooble's Avatar
 
Join Date: Jul 2004
Location: In my box.
Posts: 4,434
Rep Power: 9 Ooble is on a distinguished road
Quote:
Originally Posted by Rory
Anyway it's better programming practice and more legible than a load of magic numbers.
Now that, I agree with.
__________________
Me :: You :: Them
Ooble is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 7:29 AM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC