|
-
Jun 25th, 2000, 07:07 AM
#1
Thread Starter
Lively Member
i use this code:
ReDim Preserve test(UBound(test) + 1) As String
test(UBound(test) + 1) = test
that is inside a public sub and the array test is decleared like this:
Global test() as string
i may have made some minor spelling errors here, thats nt the problem but it gives me the error subscript out of range any idea why?
-
Jun 25th, 2000, 07:24 AM
#2
transcendental analytic
Yup, thats because your array isn't initialized yet (no items in it) And you need to put an on error resume next to handle it
Use  
writing software in C++ is like driving rivets into steel beam with a toothpick.
writing haskell makes your life easier:
reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.
-
Jun 25th, 2000, 08:16 AM
#3
Hyperactive Member
You see, the subscript range for an unused array without range declarations is 0-0. That is nothing, so whatever you try to put to it, it'll get you an error.
Signed, Rodik ([email protected])
Programmer,usesVB6ED
===========================
Copyright©RodikCo,2002.
Dont mind this signature ;] Its old
-
Jun 25th, 2000, 09:11 AM
#4
Thread Starter
Lively Member
i put the on error thing and it seems to work, but i redimmed it so why did it complain still?
-
Jun 25th, 2000, 09:14 AM
#5
transcendental analytic
not even 0-0 because thats actually one item: 0
it's more like 0 -1
Use  
writing software in C++ is like driving rivets into steel beam with a toothpick.
writing haskell makes your life easier:
reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.
-
Jun 25th, 2000, 09:43 AM
#6
transcendental analytic
hmm, odd, put a break there and then in immediate window:
?UBound(test)
Use  
writing software in C++ is like driving rivets into steel beam with a toothpick.
writing haskell makes your life easier:
reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.
-
Jun 25th, 2000, 09:48 AM
#7
Lively Member
You're redimming it with the ubound operator, then adding 1, which is correct in the redim statement, but in the next line, you're accessing it with the ubound operator + 1 again, which will give you an error. Try this instead...
Code:
ReDim Preserve test(UBound(test) + 1) As String
test(UBound(test)) = "test"
or this
Code:
TmpVal=ubound(test)+1
Redim Preserve Test(TmpVal) as String
Test(TmpVal)="Test"
-
Jun 25th, 2000, 09:59 AM
#8
Thread Starter
Lively Member
i feel like an idiot, i forgot it changed the ubound lol thanks
-
Jun 25th, 2000, 10:21 AM
#9
transcendental analytic
Me.2 I feel stupid, now i need some sleep 6:15 am now
Use  
writing software in C++ is like driving rivets into steel beam with a toothpick.
writing haskell makes your life easier:
reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.
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
|