Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Multiple User Inputs question.

Status
Not open for further replies.

Naranll

Technical User
Aug 14, 2007
10
US
Hey all, first I'd like to thank these boards. I not have made what progress I have without them. Anyhow, I'm a User with barely remembered programming lessons and a master of copy/paste so keep that in mind for my question.

I currently have a dialog that takes several pieces of info from the user and then throws them in the correct places on the correct screens, even with some rudimentary accuracy checking. The user can then re-open it and go on to the next record. What I'd like to know is, is there an elegant way to take user inputs and temporarily store them for future iterations of the macro? Like maybe be able to store the last 3 first names the user inputted in a drop box of some sort?

Any help would be most appreciated!
 
Storing anything in memory which persists after macro termination is fairly unreliable, so I would recommend actually storing the information into a file. I usually have a temporary file to which I would write recent searches/results results and user preferences. You pull the information out on macro load, and you write in any changes as they happen.

[blue]When birds fly in the correct formation, they need only exert half the effort. Even in nature, teamwork results in collective laziness.[/blue]
 
The Macro doesn't actually terminate. It waits for the user to enter a key to continue before bringing back the dialog so they can switch and check screens as necessary.
 
Code:
Sub Push(ByRef arr() As String, item As String)
   Dim i As Integer
   
   For i = 1 To UBound(arr) - 1
      arr(i) = arr(i + 1)
   Next i
   
   arr(UBound(arr)) = item
End Sub

Sub Print_Array(arr() As String)
   Dim i As Integer
   
   For i = 1 to UBound(arr)
      If arr(i) <> "" Then
         msgbox arr(i)
      End If
   Next
End Sub

Sub Main()
   Dim history(3) As String
   
   Call Push(history, "one")
   Call Push(history, "two")
   Call Push(history, "three")
   Call Push(history, "four")
   Call Push(history, "five")
   'Call Push(history, "six")
   
   Call Print_Array(history)
End Sub
 
Thanks, that works perfectly... Way more elegant than anything I'd have come up with, much appreciated!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top