Photo Gallery Member List Search Calendars FAQ Ticket List Log Out


Dictionary problem...

 
Logged in as: Guest
arrSession:exec spGetSession 2,2,46604
 Active Users: There are 0 members and 0 guests.
 Users viewing this topic: none
 

 

 
  
  Printable Version
All Forums >> [Scripting] >> WSH & Client Side VBScript >> Dictionary problem...
  Do you like VisualBasicScript.com? Link to us and help spread the word about our forum. Thanks!
Page: [1]
Login
Message << Older Topic   Newer Topic >>
 Dictionary problem... - 5/3/2007 3:51:14 AM   
  danielc

 

Posts: 10
Score: 0
Joined: 3/2/2007
Status: offline
Hello all,

Below is the script i have written and a sample of the CSV file:

Option Explicit

Dim sFileName, dCodes, objFSO, ts, aLine

Const ForReading = 1

sFileName = "c:\test3a.txt"

Set dCodes = CreateObject("Scripting.Dictionary")
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set ts = objFSO.OpenTextFile(sFileName, 1)
  
Do Until ts.AtEndOfStream
   aLine = Split(ts.ReadLine, ",")
   dCodes.Add aLine(0), aLine(1)
Loop

ts.close
objFSO.close

Brent, Givens
Arturo, Jimenez
Lillie, Campbell
Robin, Posmanter
Alice, Fletcher
Chu, Vang
Debra, Logan
Debra, Nordyke


What is happening is that the script will operate correctly and then error out when it reads the second Debra.  My assumption is that key can only contain one Debra and not a duplicate.  Am I correct and how can I get around this?

Thank you in advance for your assistance,

Daniel
 
 
Post #: 1
 
 RE: Dictionary problem... - 5/3/2007 7:16:25 AM   
  dm_4ever


Posts: 2724
Score: 46
Joined: 6/29/2006
From: Orange County, California
Status: offline
You're correct, you can't have duplicates.

good little read: http://www.microsoft.com/technet/scriptcenter/resources/begin/ss0906.mspx

What is it you are trying to accomplish?

_____________________________

dm_4ever

My philosophy: K.I.S.S - Keep It Simple Stupid
Read Me: http://www.visualbasicscript.com/m_24727/tm.htm
Frequently Asked Stuff: http://www.visualbasicscript.com/m_47117/tm.htm

(in reply to danielc)
 
 
Post #: 2
 
 
 
  

If you found our site useful please link to us <a href="http://www.visualbasicscript.com">VisualBasicScript.com</a>.
All Forums >> [Scripting] >> WSH & Client Side VBScript >> Dictionary problem... Page: [1]
Jump to:





New Messages No New Messages
Hot Topic w/ New Messages Hot Topic w/o New Messages
Locked w/ New Messages Locked w/o New Messages
 Post New Thread
 Reply to Message
 Post New Poll
 Submit Vote
 Delete My Own Post
 Delete My Own Thread
 Rate Posts