Discussion:
Clearing Memory of an Array
(too old to reply)
Ragehammer >
2004-10-27 23:59:30 UTC
Permalink
Hello, I'm sort of a newb to VBA, so I got a question for you all.


I've got a 3 slot array which is taking string values from text boxe
on a user form. At the end of the routine that calls the form, I us
the "Unload UserForm1" method. I only want to clear those 3 memor
locations, but it seems that all memory locations in the routine ar
cleared.

Question: Is there a way to clear only the memory on the 3 slots in th
array or only those directly linked to "UserForm1"?

If you need more info from me, please let me kno

--
Message posted from http://www.ExcelForum.com
Jezebel
2004-10-28 05:41:05 UTC
Permalink
1) What do you mean by 'slot' ?

2) Are you trying to erase the array, or simply clear its contents?

3) What's the connection between the form and the array?
Post by Ragehammer >
Hello, I'm sort of a newb to VBA, so I got a question for you all.
I've got a 3 slot array which is taking string values from text boxes
on a user form. At the end of the routine that calls the form, I use
the "Unload UserForm1" method. I only want to clear those 3 memory
locations, but it seems that all memory locations in the routine are
cleared.
Question: Is there a way to clear only the memory on the 3 slots in the
array or only those directly linked to "UserForm1"?
If you need more info from me, please let me know
---
Message posted from http://www.ExcelForum.com/
Ragehammer >
2004-10-28 13:32:17 UTC
Permalink
Code in form Mod

-Sub btnOK_Click()
Public_Array(1) = tboxFirst
Public_Array(2) = tboxMI
Public_Array(3) = tboxLast
Userform1.Hide
End Sub[/I}

Code in Mod1

[I]Sub InsertName()
Userform1.Show
'insert name
Selection.TypeText Text:= Public_Array(1) & Public_Array(2)
Public_Array(3)
End Sub-


What do I insert at the end of the second sub to clear 1, 2 & 3

--
Message posted from http://www.ExcelForum.com
Jezebel
2004-10-29 05:32:51 UTC
Permalink
for i = 1 to 3
Public_Array(i) = ""
Next

But better not to use an array at all ----

Sub InsertName()

With New Userform1
.Show vbModal
If .UserOK then
Selection.TypeText Text:= .tboxFirst & .tboxMI & .tboxLast
End if
.Unload
End With

End Sub



Code in form ----

Private mUserOK as boolean

Public Property Get UserOK() as boolean
UserOK = mUserOK
End Property

Sub btnOK_Click()
mUserOK = TRUE
Me.Hide
End Sub
Post by Ragehammer >
Code in form Mod
-Sub btnOK_Click()
Public_Array(1) = tboxFirst
Public_Array(2) = tboxMI
Public_Array(3) = tboxLast
Userform1.Hide
End Sub[/I}
Code in Mod1
[I]Sub InsertName()
Userform1.Show
'insert name
Selection.TypeText Text:= Public_Array(1) & Public_Array(2) &
Public_Array(3)
End Sub-
What do I insert at the end of the second sub to clear 1, 2 & 3?
---
Message posted from http://www.ExcelForum.com/
Joost Verdaasdonk
2004-11-12 22:06:50 UTC
Permalink
Hi,

Seams to me you don't need an array? (the way you are
using this code) Let alone need three that you can hold
in one as wel.

I don't see any matrix values in you're subs. Seams
you're trying to output the text of textboxes to the
Selection?

If you look at Jezebels first answer he pretty much tells
you a better way

If you wan't to clear the array you can use the Erase
method:
Erase NumArray (look-up F1 in VBE)

Loading...