Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Programming / November 2004

Tip: Looking for answers? Try searching our database.

Clearing Memory of an Array

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Ragehammer - 28 Oct 2004 00:59 GMT
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 - 28 Oct 2004 06:41 GMT
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?

> Hello, I'm sort of a newb to VBA, so I got a question for you all.
>
[quoted text clipped - 11 lines]
> ---
> Message posted from http://www.ExcelForum.com/
Ragehammer - 28 Oct 2004 14:32 GMT
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 - 29 Oct 2004 06:32 GMT
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

> Code in form Mod
>
[quoted text clipped - 18 lines]
> ---
> Message posted from http://www.ExcelForum.com/
Joost Verdaasdonk - 12 Nov 2004 22:06 GMT
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)
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.