Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP 3 Classic ASP Active Server Pages 3.0 > Classic ASP Basics
Password Reminder
Register
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
Classic ASP Basics For beginner programmers starting with "classic" ASP 3, pre-".NET." NOT for ASP.NET 1.0, 1.1, or 2.0
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Classic ASP Basics section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developersí questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Display Modes
  #1 (permalink)  
Old October 30th, 2004, 04:06 AM
Authorized User
 
Join Date: Mar 2004
Location: , , .
Posts: 84
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to gmoney060 Send a message via MSN to gmoney060
Default Multidemmesional Arrays OR arrays

This is the following strings I have:

"1 13032928 Grant McElroy"
"2 10928308 Bob Long"
"3 10923809 Joe Smoe"

I want to put the following into an array to work like this:
Users(0,0) = 1
Users(0,1) = 13032928
Users(0,3) = McElroy
Users(1,2) = 10928308

I just do not know how to put the values into a array, when i have to split stuff ext?



Reply With Quote
  #2 (permalink)  
Old October 30th, 2004, 04:20 AM
Friend of Wrox
 
Join Date: Jun 2003
Location: Bangalore, KA, India.
Posts: 2,480
Thanks: 0
Thanked 0 Times in 0 Posts
Default

You can use Split function to get that work, but the delimeiter in this case is SPACE, which also occurs within the name part, so you got to think on that. Is there anyway you can have that values come as comma separated. Then it would be easy to split them at one short and populate into array.

Cheers!

_________________________
- Vijay G
Strive for Perfection
Reply With Quote
  #3 (permalink)  
Old October 31st, 2004, 01:30 AM
Authorized User
 
Join Date: Mar 2004
Location: , , .
Posts: 84
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to gmoney060 Send a message via MSN to gmoney060
Default

I actually want the first name, and last name seperate. This is what i have now, but it is not working.

Code:
<%
'Option Explicit
' Set up constants
Const ForReading = 1 
Const Create = False

' Declare local variables
Dim objFSO         ' FileSystemObject
Dim TS             ' TextStreamObject
Dim strLine        ' local variable to store Line
Dim strFileName    ' local variable to store fileName

strFileName = Server.MapPath("/demo/dci.txt")

' Instantiate the FileSystemObject
Set objFSO = Server.CreateObject("Scripting.FileSystemObject")

' use Opentextfile Method to Open the text File
Set TS = objFSO.OpenTextFile(strFileName, ForReading, Create)
Do While Not TS.AtEndOfStream
    TempUser = TS.ReadLine
    UserInfo = Split(TempUser," ")
    Response.Write UserInfo(0)
Loop 
'Response.Write UserInfo(1) & "<BR>"
TS.Close 
Set TS = Nothing
Set objFSO = Nothing
%>
The file is located at: http://www.topdeckcards.com/demo/dci.txt

It does not create a correct array, everything is put into UserInfo(0)... So it doesnt split the value.

Reply With Quote
  #4 (permalink)  
Old November 1st, 2004, 03:42 PM
Friend of Wrox
 
Join Date: Jun 2003
Location: Bangalore, KA, India.
Posts: 2,480
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Replace your While loop with this one
Code:
Do While Not TS.AtEndOfStream
    TempUser = Replace(Replace(TS.ReadLine,vbTab&vbTab,","),vbTab,",")
    UserInfo = Split(TempUser,",")
    for i = 0 to ubound(UserInfo)
    Response.Write "<b>UserInfo(" & i & "):</b>" & Trim(UserInfo(i)) & " "
    Next
    Response.Write "<br>"
Loop
Since Tab usage within the text file wasn't regular, the code marked in Blue uses two replace functions, one replacing multiple tabs and the other replacing single tab with COMMA.

Hope that helps.
Cheers!

_________________________
- Vijay G
Strive for Perfection
Reply With Quote
Reply


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 Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Help With Arrays Crippy Ruby 2 March 6th, 2013 05:59 PM
arrays ozPATT Excel VBA 2 November 4th, 2005 06:11 AM
Arrays tajin Excel VBA 0 June 20th, 2004 10:07 AM



All times are GMT -4. The time now is 10:33 PM.


Powered by vBulletin®
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.