Go Back  Xtreme Visual Basic Talk > Legacy Visual Basic (VB 4/5/6) > General > redim array error


Reply
 
Thread Tools Display Modes
  #1  
Old 05-17-2001, 11:06 PM
koo9
Guest
 
Posts: n/a
Question redim array error


I am working on an Undo function, what happened is the undo function keep track of an array of strings for the undo information of richtext box. I also have anther event on textbox_change(), so whenever the Undo function undo the text within the textbox_change() will be activated and once the textbox_change() activate, it will update the string array to keep the undo info for the textbox, then I got an error says:

array size is fit or locked. error 10.

how can I get arround that?



Reply With Quote
  #2  
Old 05-17-2001, 11:42 PM
karimahta karimahta is offline
Senior Contributor

* Guru *
 
Join Date: Mar 2000
Location: Christchurch, New Zealand
Posts: 470
Lightbulb Re: redim array error

Haven't ever seen this before but if you go to the Search tab in your help screen and enter the following string (<U>including the quotes</U>) you should get a few articles that will help.

<font color=red>"This array is fixed or temporarily locked"</font color=red>


Good Luck

<font color=blue>Better to remain a fool than write a quote and remove all doubt. (****!!)</font color=blue>
Reply With Quote
  #3  
Old 05-18-2001, 01:59 AM
Ad1 Ad1 is offline
Senior Contributor

Retired Moderator
* Expert *
 
Join Date: Feb 2001
Location: UK
Posts: 1,287
Default Re: redim array error

without seeing your function I can't be sure but with some of the ones I have dabbled with I used a boolean in the text change event called booUndo, when the undo function is called booUndo is set to true and in the text change all the code is inside
<pre>if booUndo=false then
'your code
endif</pre>hope this helps

Reply With Quote
  #4  
Old 05-18-2001, 06:19 AM
Laurent Laurent is offline
Senior Contributor

Retired Leader
* Expert *
 
Join Date: Apr 2001
Location: canada, quebec
Posts: 1,334
Default Re: redim array error

my first tought would be that you declared an array (10) with a final size you could always try a code like this
you set it first at (1) then everytime you want to add more cells you do this
redim preserve array(array.upperbound + 1)
enter the newest infoin the last cell

then if you want to limit the undo to lets say 10 events
if array.upperbound < 9 then redim....
else you erase the first cell and do this

for i = 0 to array.upperboud - 1
array(i) = array(i + 1)
next
array(i)=new entry



I'll be among the best soon, very soon!!!
__________________
Still tons to learn!
Reply With Quote
  #5  
Old 05-18-2001, 06:52 AM
anhmytran anhmytran is offline
Senior Contributor

Retired Moderator
* Guru *
 
Join Date: Aug 1999
Location: Hartford, Connecticut, 06
Posts: 1,487
Default Re: redim array error

I have been working with arrays, and I have never get the Error 10.
I can get Error 10 when I use Err.Raise 10 only.

Please, give me the code that causes Error 10?

AnhMy_Tran
Reply With Quote
  #6  
Old 05-18-2001, 06:57 AM
SATISHNAIR
Guest
 
Posts: n/a
Default Re: redim array error

Paste your code here that causes the error

"Every problem has a solution or atleast a workaround - "
Reply With Quote
  #7  
Old 05-20-2001, 10:48 AM
koo9
Guest
 
Posts: n/a
Default Re: redim array error

I will post it later.. since I am not in my office now..

Reply With Quote
  #8  
Old 05-22-2001, 09:02 AM
koo9
Guest
 
Posts: n/a
Default Code

Dim UndoStackObjective() As String, UndoStageObjective, UndoingObjective

Private Sub rtxtBackGround_Change()
projDocSave = True
' Records the last changes made
ReDim Preserve UndoStackBackGround(UBound(UndoStackBackGround) + 1)
'increase the stack size
UndoStackBackGround(UBound(UndoStackBackGround)) = rtxtBackGround.Text
'.Text 'add the current state
If Not UndoingBackGround Then
UndoStageBackGround = UndoStageBackGround + 1
End If
'change the current stage

End Sub


Private Sub mnuUndo_Click()
Select Case TextBoxClicked
Case "rtxtObjective"
UndoingObjective = True
'prevent doubling-up
UndoStageObjective = UndoStageObjective - 1
'go back a stage
If UndoStageObjective <= 0 Then
UndoStageObjective = 0
'protection from errors
End If
' For richtextboxes
rtxtObjective.Text = UndoStackObjective(UndoStageObjective)
UndoingObjective = False


'I posted just one case , here it is BackGround case.

Case "rtxtBackGround"
UndoingBackGround = True
'prevent doubling-up
UndoStageBackGround = UndoStageBackGround - 1
'go back a stage
If UndoStageBackGround <= 0 Then
UndoStageBackGround = 0
'protection from errors
End If
' For richtextboxes
rtxtBackGround.Text = UndoStackBackGround(UndoStageBackGround)
UndoingBackGround = False
Case "rtxtWorkplan"
UndoingWorkplan = True
'prevent doubling-up
UndoStageWorkplan = UndoStageWorkplan - 1
'go back a stage
If UndoStageWorkplan <= 0 Then
UndoStageWorkplan = 0
'protection from errors
End If
' For richtextboxes
rtxtWorkplan.Text = UndoStackWorkplan(UndoStageWorkplan)
UndoingWorkplan = False
Case "rtxtbenefit"
UndoingBenefit = True
'prevent doubling-up
UndoStageBenefit = UndoStageBenefit - 1
'go back a stage
If UndoStageBenefit <= 0 Then
UndoStageBenefit = 0
'protection from errors
End If
' For richtextboxes
rtxtbenefit.Text = UndoStackBenefit(UndoStageBenefit)
UndoingBenefit = False
Case "rtxtImpact"
UndoingImpact = True
'prevent doubling-up
UndoStageImpact = UndoStageImpact - 1
'go back a stage
If UndoStageImpact <= 0 Then
UndoStageImpact = 0
'protection from errors
End If
' For richtextboxes
rtxtImpact.Text = UndoStackImpact(UndoStageImpact)
UndoingImpact = False
Case "rtxtDeliverables"
UndoingDeliverables = True
'prevent doubling-up
UndoStageDeliverables = UndoStageDeliverables - 1
'go back a stage
If UndoStageDeliverables <= 0 Then
UndoStageDeliverables = 0
'protection from errors
End If
' For richtextboxes
rtxtDeliverables.Text = UndoStackDeliverables(UndoStageDeliverables)
UndoingDeliverables = False

End Select



End Sub


Reply With Quote
  #9  
Old 05-22-2001, 10:59 AM
anhmytran anhmytran is offline
Senior Contributor

Retired Moderator
* Guru *
 
Join Date: Aug 1999
Location: Hartford, Connecticut, 06
Posts: 1,487
Default Problems with Declarations

You have problems with Declarations and Redim arrays.

1- You have incompleted declaration of variables UndoStageObjective and UndoingObjective
2- You forget to declare UndoStackBackGround, UndoingBackGround, UndoStageBackGround
and TextBoxClicked, and many more
3- you forget to Redim array before use: ReDim UndoStackBackGround(0)
5- You forget to assign a string value to TextBoxClicked before you use it in mnuUndo_Click event.

That is the reason you may encounter as many as you go along.
I cannot go as far as Error with Error code of 10.
I do not want to analyzing your code in critisizing actions without constructive help.
I will offer more help when you post only specific question rather than
a peace of code that does not work or that causes countless errors.

AnhMy_Tran
Reply With Quote
  #10  
Old 05-22-2001, 11:15 AM
koo9
Guest
 
Posts: n/a
Default Re: Problems with Declarations

sorry. i did all that you mention except
1. as you said unfinished declaration of UndoStageBackground. i just declare them as variant.

and all other things are on my program. just forget to put them up.

I have figure out a way around the problem now. thanks
for your help anyway.



Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
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

Forum Jump

Advertisement:





Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe
 
 
-->