This routine runs slower slower each time it's used. Any Ideas why? 
Author Message
 This routine runs slower slower each time it's used. Any Ideas why?

This is a part of routine that loads info from a comma separated text file
into a list box.

Using the timer function Iworked out which lines of code run slower (marked

Quote:
>).

The culprit line seems to be the wordbasic sort line (near the end of the
userform_initialise sub) but have no idea why this causes the problem.

I'm using CDO. Could this be the reason, or maybe there's a known bug in
wordbasic.sortarray?

Any help would be appreciated

Thanks in advance

Dave

Option Explicit

Dim Jobs() As String
Dim objSession As MAPI.Session
Dim objMessages As Messages
Dim ContactList() As String

Private Sub UserForm_Initialize()
  Dim Cnt As Integer, Cnt3 As Integer, Cnt2 As Integer, Cnt5 As Integer
  ReDim Staff(1 To 2, 1 To 30) As String
  Dim str1 As String
  Dim objPSTFolder As Folder
  Dim objOneMessage As Message

  Set objSession = CreateObject("MAPI.Session")
  objSession.Logon "mw", , , False, , True

  ReDim Jobs(1 To 2, 1 To 5000)

Quote:
>  Open "c:\dwgs\documents\joblist.txt" For Input As #1
>  Do While Not EOF(1)
>    Cnt3 = Cnt3 + 1
>    Input #1, Jobs(1, Cnt3), Jobs(2, Cnt3)
>    cboJobNo.AddItem Jobs(1, Cnt3), 0
>  Loop
>  Close #1

cboJobNo.RemoveItem (0)
  cboJobNo.RemoveItem (0)
  ReDim Preserve Jobs(1 To 2, 1 To cboJobNo.ListCount)
  With cboFormat
    .AddItem "Letter"
    .AddItem "Fee Quote"
    .AddItem "Report"
    .AddItem "Spec"
    .AddItem "Minutes"
  End With
  With cboSalut
    .AddItem "Yours sincerely"
    .AddItem "Yours faithfully"
    .AddItem "Big hugs & kisses"
    .AddItem "Go forth & multiply"
  End With
  Open "c:\dwgs\documents\stafflist.txt" For Input As #1
  Do While Not EOF(1)
    Cnt2 = Cnt2 + 1
    Input #1, Staff(1, Cnt2), Staff(2, Cnt2), str1, str1
    cboAuthInit.AddItem Staff(1, Cnt2)
    CboTypInit.AddItem Staff(1, Cnt2)
    cboAuthName.AddItem Staff(2, Cnt2)
  Loop
  Close #1
  ReDim Preserve Staff(1 To 2, 1 To Cnt2)
  cboJobNo.ListIndex = 0
  cboFormat.ListIndex = 0
  cboAuthInit.Value = Application.UserInitials
  CboTypInit.Value = Application.UserInitials
  Set objPSTFolder = objFindTargetFolder("Top of Personal Folders", "Mann
Williams' Contacts")
  Set objMessages = objPSTFolder.Messages
  ReDim ContactList(objMessages.Count)

  For Each objOneMessage In objMessages
    ContactList(Cnt) = objOneMessage
    Cnt = Cnt + 1
  Next

Quote:
>  WordBasic.sortarray ContactList

  For Cnt5 = 1 To UBound(ContactList)
    LboContactsNme.AddItem ContactList(Cnt5)
    Cnt5 = Cnt5 + 1
  Next Cnt5
  btTypeLetter.Enabled = False
End Sub

Private Function objFindTargetFolder(strTargetTopFolder As String,
strSearchName As String) As Folder
  Dim objInfoStores As InfoStores
  Dim objInfoStore As InfoStore
  Dim objTopFolder As Folder
  Dim objPSTFolders As Folders
  Dim i As Integer

  Set objInfoStores = objSession.InfoStores

  'This loop finds the TopFolder you specified.
  For i = 1 To objInfoStores.Count
    Set objInfoStore = objInfoStores(i)
    Set objTopFolder = objInfoStore.RootFolder
    If objTopFolder.Name = strTargetTopFolder Then 'Found PST
    End If
  Next i
  Set objPSTFolders = objTopFolder.Folders
  For i = 1 To objPSTFolders.Count
    If objPSTFolders.Item(i).Name = strSearchName Then
      Exit For
    End If
  Next i
  Set objFindTargetFolder = objPSTFolders.Item(i)
  Set objTopFolder = Nothing
  Set objPSTFolders = Nothing
  Set objInfoStores = Nothing
  Set objInfoStore = Nothing
End Function



Wed, 02 Jun 2004 03:21:31 GMT  
 
 [ 1 post ] 

 Relevant Pages 

1. Slow, slow, slow search on VB6, ADO and SS7

2. VB4 is slow..slow....slow

3. Insert into SQL Server slow, slow, slow...

4. VB5, Run-time much slower than Design-time

5. Why is ADO 8 times slower than DAO?

6. Why DB connection slow first time around on XP

7. Why Comm 2 runs slower that Comm 1

8. Why VB4 runs slow in LAN?

9. Please Help...Why does this run so slow?

10. Why project RUNS SLOWER IN WINDOWS 2000 ???

11. TIME$ Slow Down In Long Running BASIC pgm

12. Slow run time ???

 

 
Powered by phpBB® Forum Software