|
-
Jun 20th, 2001, 10:35 AM
#1
Split into an array?
i just came across this problem, and was wondering if someone could explain it to me... i have simplified the code...
Code:
Dim arrReferences()
arrReferences = Split(strTemp, ",")
the above code would always throw a type mismatch error... however, when i alter it to:
Code:
Dim arrReferences ' notice i removed the parentheses
arrReferences = Split(strTemp, ",")
it works like a charm... why would this be?... because of variant types?... i assumed that vb would prefer me telling it that i would be using this variable as an array...? i'm just curious...
-
Jun 20th, 2001, 10:44 AM
#2
Frenzied Member
It is just a quirk of VBScript. I've complained about it many times.
Travis, Kung Foo Journeyman
As always, RTFM.
WWW Standards: HTML 4.01, CSS Level 2, ECMA 262 Bindings to DOM Level 1, JavaScript 1.3 Guide and Reference
Perl: Learn Perl, Llama, Camel, Cookbook, Perl Monks, Perl Mongers, O'Reilly's Perl.com, ActiveState, CPAN, TPJ, and use Perl;
YBMS, but Mozilla doesn't.
-
Jun 20th, 2001, 11:27 AM
#3
Frenzied Member
[2nd Attempt to Post: I think I just saw the DB take a crap.]
I don't think VB/VBScript deals with pointers. I think the = operator can't recast an array to fit the results of the Split, but it can shove an array into a variant and let memory management clean up the mess.
I could be wrong. I'm sure variants are just memory pointers to the OS, but I don't think the VB engines are aware of the smoke and mirrors.
Anyway, you can't do cool things like...
Code:
myArray(3..7) = Split(myString, myDelim, 5)
But I guess I've been spoiled by the Poetry of Perl.
Travis, Kung Foo Journeyman
As always, RTFM.
WWW Standards: HTML 4.01, CSS Level 2, ECMA 262 Bindings to DOM Level 1, JavaScript 1.3 Guide and Reference
Perl: Learn Perl, Llama, Camel, Cookbook, Perl Monks, Perl Mongers, O'Reilly's Perl.com, ActiveState, CPAN, TPJ, and use Perl;
YBMS, but Mozilla doesn't.
-
Jun 20th, 2001, 12:32 PM
#4
Black Cat
I don't think VB/VBScript deals with pointers.
It does, but it shields the programmer from them. (There are hidden functions like StrPtr and VarPtr in VB that you can use to get pointers). I would think anything declared as a Variant or Object would have to be a pointer. It wouldn't make sense to me otherwise.
Josh
Get these: Mozilla Opera OpenBSD
I have books for sale: "MCSD in a Nutshell" and "VB Distributed Exam Cram" - PM me for details. Will also trade for a decent ATX Pentium 2 MB/CPU/RAM combo.
-
Jun 20th, 2001, 04:41 PM
#5
Frenzied Member
The short answer here is:
Change
Dim arrReferences()
to
Dim arrReferences
oOOo--oOOo
__ /\/\onte96
oOOo--oOOo
Senior Programmer/Analyst
MCP
[email protected]
[email protected]
Your results may vary.. some restrictions may apply.. pricing and participation may vary.. not available in all states.. professional driver closed course..quantities limited..
-
Jun 21st, 2001, 09:15 AM
#6
thanks, but i think that i've already discussed that... i'm simply curious of why this has to be? i assumed that vb would appreciate me preparing it to use an array.. hence my dimensioning a dynamic array... instead, vb requires that the coder not use the parentheses... ?
-
Jun 21st, 2001, 07:33 PM
#7
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|