Wrox Programmer Forums

Need to download code?

View our list of code downloads.

| 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 Search this Thread Display Modes
  #1 (permalink)  
Old August 21st, 2008, 07:31 AM
Registered User
 
Join Date: Aug 2006
Location: , , .
Posts: 9
Thanks: 0
Thanked 0 Times in 0 Posts
Default Illegal Assignment

I'm trying to concatenate a string in a for loop, which sounds quite simple in principle, but I'm getting the following error:

Microsoft VBScript runtime error '800a01f5'
Illegal assignment: 'I'

This is the code that I'm running:

tmpString = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVW XYZ1234567890"
numSaltChars = 10
sSalt = ""
i = 0
for i = 1 to numSaltChars
    Randomize
    pos = Round(Rnd * Len(tmpString)) + 1
    sSalt = sSalt & tmpString.substring(pos,1)
next

I can't see what's wrong with the code. Any help would be appreciated.

Reply With Quote
  #2 (permalink)  
Old August 21st, 2008, 01:18 PM
Friend of Wrox
 
Join Date: Jun 2008
Location: Snohomish, WA, USA
Posts: 1,649
Thanks: 3
Thanked 141 Times in 140 Posts
Default

VBScript does *NOT* support METHODS on strings.

    tmpString.substring(pos,1)

You are trying to use a substring method, but that's only available in JavaScript and in the .NET languages (and Java, I guess).

Strings are *NOT* objects in VBScript. They are primitive types. So you have to use built in functions.

**********

Various other goofs in your code:

You call RANDOMIZE each time through the loop. That will actually *DESTROY* any attempts to get good random numbers. RANDOMIZE should be called once *PER PAGE* only.

You are using ROUND where you should use INT. ROUND *could* give you a number that is one greater than the length of your string, so you would get an "out of bounds" error!

Finally, you set i=0 for no reason at all, since the very next line will throw away that value.

********************

SO:

Code:
CONST numSaltChars = 10
Randomize ' remember, once PER PAGE!

tmpString = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890"
sLen = Len(tmpString)
sSalt = ""

for i = 1 to numSaltChars
    sSalt = sSalt & Mid( tmpString, 1 + INT(sLen * RND()), 1 )
next
Reply With Quote
  #3 (permalink)  
Old August 22nd, 2008, 06:21 AM
Registered User
 
Join Date: Aug 2006
Location: , , .
Posts: 9
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Great, thanks for the help.

Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
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
ERROR: Illegal characters in path owen_xgy .NET Framework 2.0 8 April 2nd, 2008 10:21 AM
Illegal operation on empty result set. amisrivas JSP Basics 2 February 19th, 2008 11:49 PM
Illegal assignment: 'adCmdText' jackiew ASP.NET 1.0 and 1.1 Basics 1 August 23rd, 2007 09:29 AM
Illegal key size rnmisrahi BOOK: Beginning Cryptography with Java 3 January 8th, 2007 09:06 PM
ParseException:Illegal character inAxis Webservice manaspanda J2EE 1 February 23rd, 2004 11:49 AM



All times are GMT -4. The time now is 11:17 PM.


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