Hollinar Posted December 14, 2006 Share Posted December 14, 2006 Okay, a piece of a script I'm making contains code similar to this: Dim $var1 = InputBox("Please enter a number", "Please entar a number.", "", " M") Dim $var2 Dim $e = 0 While $e < $var1 + 1 $e = $e + 1 Global $stat[$e] $var2[$e] = InputBox("Enter a number", "Enter a number.", "", " M") WEnd Now, when I run this code it says: Line 0 (File "<edited out>"): $var2[$e] = InputBox("Enter a number", "Enter a number.", "", " M") $var2^ ERROR Error: Badly formated variable or macro. Is there a way to get what I need done? or will I have to increase the code exponentially to compensate? Link to comment Share on other sites More sharing options...
JerryD Posted December 14, 2006 Share Posted December 14, 2006 You're DIMing $var2 as a string and then trying to use it as an array. An array of [0] size is just a variable. Use: $var2 = InputBox("Enter a number", "Enter a number.", "", " M") If you need an array, then declare it as an array and ReDim as needed Dim $var1, $var2[1], $e Global $stat[1] $var1 = InputBox("Please enter a number", "Please entar a number.", "", " M") ReDim $var2[$var1+1] $e = 0 While $e < $var1 + 1 $e = $e + 1 $var2[$e] = InputBox("Enter a number", "Enter a number.", "", " M") WEnd ReDim $stat[] as needed. If you don't know the size of the array, use UBound. Link to comment Share on other sites More sharing options...
Hollinar Posted December 14, 2006 Author Share Posted December 14, 2006 (edited) Excellent, thanks... Perhaps I'll post the script when I've got it past the "heavy-editing-beta" stage... I make changes to it multiple times a day... it's at 484 lines of code right now, and it's an auto-leveller/trainer bot for a game(even though the game is older) EDIT------------ I feel I should point out that the $stat variable was clutter from an old version of the function that statement resides in, and I failed to remove it... I also must thank you for pointing it out, or else it probably would have gone un-noticed until I released the code Edited December 14, 2006 by Hollinar Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now