What is the exact opposite statement for this?

prabha_friend

Prabhakaran Karuppaih
Local time
Today, 23:30
Joined
Mar 22, 2009
Messages
1,034
Code:
 If Not Not Temp Then ReDim Preserve Temp(UBound(Temp) + 1) Else ReDim Temp(0)

I know the code should look something like this:
Code:
If Ubound(Temp)>0 then somecode else erase Temp

How to erase only the last element of an array?
 
If Ubound(Temp)>0 then
Redim Preserve Temp(UBound(Temp)-1)
Else
erase Temp
End If
 
Hi Arnel,
What you are suggesting is a redimensioning statement. I want don't to redim it but an exact opposite of it. Is there any?
 
How about telling/showing us exactly what you want with a small example?
Suppose you have an array X(3) where
Code:
x(0)=3 
x(1) = 6
x(2) =12
x(3) =8
Can you restate your requirement using this as an example?
 
Hi jd,
I have an habit of using a temp() array to store values temporary. For more temporary values I just top-up on it using redim preserve. Now I want to clear their memory once their purpose is solved.

Code:
 [SIZE=3][FONT=Verdana][SIZE=2]Case 13 'Picture
    With SourceFile.Worksheets(CStr(SlideNshapes!Shape_Sheet)).Range(CStr(SlideNshapes!Shape_Range))
        Select Case SlideNshapes!Shape_Function_Needed
            Case "PasteAsPicture"
                .Copy
                If Not Not Temp Then ReDim Preserve Temp(UBound(Temp) + 2) Else ReDim Temp(1)
                Set Temp(UBound(Temp) - 1) = ppt.Slides.FindBySlideID(SlideNshapes!Slide_ID).Shapes.PasteSpecial(ppPasteBitmap)
                With Temp(UBound(Temp) - 1)
                    Temp(UBound(Temp)) = Array("Top", "Left", "Height", "Width")
                    For Each element In Temp(UBound(Temp))
                       CallByName Temp(UBound(Temp) - 1), element, VbLet, CallByName(ppt.Slides.FindBySlideID(SlideNshapes!Slide_ID).Shapes(SlideNshapes!ShapeName_as_in_BRD), element, VbGet)
                    Next element
[I][U]'Here I want to clear the UBound[/U][/I][/SIZE][/FONT][/SIZE]
 [SIZE=3][FONT=Verdana][SIZE=2]                End With
            ppt.Slides.FindBySlideID(SlideNshapes!Slide_ID).Shapes(SlideNshapes!ShapeName_as_in_BRD).Delete
        End Select
    End With[/SIZE][/FONT][/SIZE]
 
'Here I want to clear the UBound

Does this mean
- remove the value of the ubound element
- reDim the array to set the ubound(x) to ubound(x) -1?
 
why bother?

if you know the array is not available to use, you don't need to redim it, do you?

-----
ok, I see you are trying to reduce the size of an array.

why not just hold the upper value in a variable somewhere , and just extend the array if and when you need to, by say another 10 or 20 elements. this is a better technique as redimming an array for every new item is a very slow process, relatively.
 
Ok. I am going with the Redim Preserve. Thank you all. Let's hope Microsoft will add will element argument (optional) to erase statement. (anyway it's no use for the example code I have quoted as I am getting an 'Array is fixed or locked' whenever I try to modify its structure - that's why redim preserve Temp(ubound(Temp)+2))
 
Women can't be this much smarter
I think this is inappropriate on this site. We expect you to treat all groups of people with respect in your posts. Please don't insult groups of people based on their sex, race, religion or whatever.
Thanks,
 

Users who are viewing this thread

Back
Top Bottom