-
Out of Memory error in Outlook 2007 form
I have a form with a listbox, a textbox, and a button. I paste a multi-line chunk of text into the textbox and push the button to parse the text into a listbox.
I us the following code:
[VBA]Private Sub cmdQuickAdd_Click()
Dim sTmp As String, iPos1 As Integer, iPos2 As Integer
sTmp = txtQuickAdd.Text
iPos1 = 1
iPos2 = InStr(sTmp, vbCrLf)
Do While iPos2
lstTasks.AddItem Mid$(sTmp, iPos1, iPos2 - iPos1)
iPos1 = iPos2 + 2
iPos2 = InStr(iPos1, sTmp, vbCrLf)
Loop
End Sub[/VBA]
The first time the form runs, it seems to work fine. Subsequent loadings of the form result in Out of Memory errors that persist until I quit an restart Outlook 2007.
Any ideas? Can the textbox hold all the clipboard characters?
-
Simplify!!
[vba]Private Sub cmdParse_Click()
lstTasks.List() = Split(txtQuickAdd.Text, vbCrLf)
End Sub[/vba]
Enjoy!
Edit: As for the out of memory, I believe listboxes and comboboxes are limited to 1000 values (0-999). The following code will stop you from adding more than a 1000 values to your listbox:
[VBA]Private Sub cmdParse_Click()
Dim vals
vals = Split(txtQuickAdd.Text, vbCrLf)
If UBound(vals) > 999 Then
MsgBox "Too many line items!", vbCritical, "D'oh!"
Else
lstTasks.List() = vals
End If
End Sub[/VBA]
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules