listview loading problem... plss help (using function)

Reply

Join Date: Jul 2007
Posts: 113
Reputation: jaasaria is an unknown quantity at this point 
Solved Threads: 1
jaasaria's Avatar
jaasaria jaasaria is offline Offline
Junior Poster

listview loading problem... plss help (using function)

 
0
  #1
Feb 14th, 2009
hi guyzz... i have more than 1000 datas in my tables i loaded it in the listview using function..

but i have problem in loading it.. it consume almost 9 second to load all in the listview...

i think it is in my coding.. i would like to minimize it. here my code.

Private Sub userPriceList1()
Set rsFltUser = Nothing
Set rsFltUser = OpenRS("Select branchcode,branchname,item_Number,item_name,balance_unitcost,balance_unit from itemlist order by item_name")

With rsFltUser
        If .RecordCount <> 0 Then
            .MoveFirst
            Do While Not .EOF
                Set lstitems = frmPOS.ListView2.ListItems.Add(1, , !branchcode & " - " & !branchname) 
                lstitems.SubItems(1) = IIf(IsNull(!item_Number), "", (!item_Number))
                lstitems.SubItems(2) = IIf(IsNull(!item_name), 0, !item_name)
                lstitems.SubItems(3) = FipoMethod(lstitems.SubItems(1), IIf(IsNull(!balance_unitcost), 0, !balance_unitcost))
                .MoveNext
            Loop
    End If
End With
End Sub



Private Function FipoMethod(itmNO As String, Optional SCost As Currency) As Currency
Dim rs2 As ADODB.Recordset
Set rs2 = Nothing
Set rs2 = OpenRS("select item_number,srp_value,srp_setup  from itemlist where item_number = '" & itmNO & "'")

With rs2
If .RecordCount <> 0 Then
If IsNull(!srp_value) = True Then !srp_value = 0
Select Case !srp_setup
Case 0 
    FipoMethod = Format(IIf(IsNull(!srp_value), 0, !srp_value), "standard")
Case 1
    FipoMethod = Format(SCost + (CCur(SCost) * ("." & Val(!srp_value))), "standard")
Case 2
    FipoMethod = Format(CCur(SCost) + CCur(!srp_value), "standard")
End Select
End If
End With
Set rs2 = Nothing
End Function


i tried already the byref and byval...



any suggestion wil be appreciated.

thx in advance
Reply With Quote Quick reply to this message  
Join Date: Feb 2008
Posts: 509
Reputation: selvaganapathy is an unknown quantity at this point 
Solved Threads: 88
selvaganapathy's Avatar
selvaganapathy selvaganapathy is offline Offline
Posting Pro

Re: listview loading problem... plss help (using function)

 
0
  #2
Feb 15th, 2009
Hi,

Try ADODB.RecordSet.GetRows () Method which returns array of records. It may seem to be fast.
KSG
Reply With Quote Quick reply to this message  
Join Date: Apr 2007
Posts: 102
Reputation: SCBWV is an unknown quantity at this point 
Solved Threads: 14
SCBWV SCBWV is offline Offline
Junior Poster

Re: listview loading problem... plss help (using function)

 
0
  #3
Feb 15th, 2009
You can also try LockWindowUpdate to prevent the ListView from updating while the records are loaded.

Private Declare Function LockWindowUpdate Lib "user32" (ByVal hwndLock As Long) As Long

Call LockWindowUpdate (ListView1.hwnd)
'load the records
Call LockWindowUpdate (0&)
Reply With Quote Quick reply to this message  
Join Date: Jul 2007
Posts: 113
Reputation: jaasaria is an unknown quantity at this point 
Solved Threads: 1
jaasaria's Avatar
jaasaria jaasaria is offline Offline
Junior Poster

Re: listview loading problem... plss help (using function)

 
0
  #4
Feb 16th, 2009
here my code and i thnk it nothing happen in loading..

Call LockWindowUpdate(ListView2.hwnd)
userPriceList1
Call LockWindowUpdate(0&)




any idea SCBWV

how to use the ADODB.RecordSet.GetRows () /??
Reply With Quote Quick reply to this message  
Join Date: Apr 2007
Posts: 102
Reputation: SCBWV is an unknown quantity at this point 
Solved Threads: 14
SCBWV SCBWV is offline Offline
Junior Poster

Re: listview loading problem... plss help (using function)

 
0
  #5
Feb 17th, 2009
Hi Jaasaria:

Try:
Call LockWindowUpdate(frmPOS.ListView2.hwnd)
userPriceList1
Call LockWindowUpdate(0&)
Reply With Quote Quick reply to this message  
Join Date: Sep 2008
Posts: 147
Reputation: samir_ibrahim is on a distinguished road 
Solved Threads: 16
samir_ibrahim's Avatar
samir_ibrahim samir_ibrahim is offline Offline
Junior Poster

Re: listview loading problem... plss help (using function)

 
0
  #6
Feb 18th, 2009
Hi,

I had a suggestion for you.

You are filling the Listview from table and function (which use table)

I suggest that you create new rs which will hold all your required data and then fill the listview from the rs.

hth
Reply With Quote Quick reply to this message  
Join Date: Jul 2007
Posts: 113
Reputation: jaasaria is an unknown quantity at this point 
Solved Threads: 1
jaasaria's Avatar
jaasaria jaasaria is offline Offline
Junior Poster

Re: listview loading problem... plss help (using function)

 
0
  #7
Feb 18th, 2009
hi.. thx for ur reply guyzzz... i solved my problem..


i access only 1 table so i did..

i declare only one recordset to query the table and make the normal computation. without using function.

thxx and hope this thread will help also to other.

thx guyzz
Reply With Quote Quick reply to this message  
Join Date: Sep 2008
Posts: 147
Reputation: samir_ibrahim is on a distinguished road 
Solved Threads: 16
samir_ibrahim's Avatar
samir_ibrahim samir_ibrahim is offline Offline
Junior Poster

Re: listview loading problem... plss help (using function)

 
0
  #8
Feb 19th, 2009
Originally Posted by jaasaria View Post
hi.. thx for ur reply guyzzz... i solved my problem..
thx guyzz
Hi,

Glad you solved your problem.

I need 2 things from you if posiible

#1 mark this thread as solved
#2 post the time that you populate the listview in first approach and the second one.

TIA.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Other Threads in the Visual Basic 4 / 5 / 6 Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC