Wrox Programmer Forums
|
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 software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old October 30th, 2004, 03:06 AM
Authorized User
 
Join Date: Mar 2004
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?



 
Old October 30th, 2004, 03:20 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 2,480
Thanks: 0
Thanked 1 Time in 1 Post
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
 
Old October 31st, 2004, 12:30 AM
Authorized User
 
Join Date: Mar 2004
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.

 
Old November 1st, 2004, 03:42 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 2,480
Thanks: 0
Thanked 1 Time in 1 Post
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





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 09:07 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.