-
I have a form with numerous textboxes and a save button,when I fill the textboxes I save the info to a file with the open statement and the text in one of the textboxes goes into a listbox to be recalled at a later date and printed out and or altered and resaved.My question is how can I save to a different file each time I fill in the textboxes with a new set of info so that I can build up the listbox with up to fifty or more items.
-
You could generate random numbers and save to files with the numbers as a file name:
Code:
Public Function GenerateRandom(minVal As Long, maxVal As Long) As Long
intr = -1
maxVal = maxVal + 1
If maxVal > 0 Then
If minVal >= maxVal Then
minVal = 0
End If
Else
minVal = 0
maxVal = 10
End If
Randomize (DatePart("s", Now) + DatePart("m", Now))
Do While (intr < minVal Or intr = maxVal)
intr = CLng(Rnd() * maxVal)
Loop
GenerateRandom = intr
End Function
code:
i = GenerateRandom(1000000, 9999999) 'Generate a number from 1000000 to 9999999
Open (App.Path & "\" & i & ".txt") For Output As #1
Print #1, text1
Close #1
-
Thank you Matthew, your reply is greatly appreciated.