943,754 Members | Top Members by Rank

Ad:
Feb 14th, 2009
0

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

Expand Post »
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
Reputation Points: 10
Solved Threads: 1
Junior Poster
jaasaria is offline Offline
123 posts
since Jul 2007
Feb 15th, 2009
0

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

Hi,

Try ADODB.RecordSet.GetRows () Method which returns array of records. It may seem to be fast.
Reputation Points: 44
Solved Threads: 101
Posting Pro
selvaganapathy is offline Offline
547 posts
since Feb 2008
Feb 15th, 2009
0

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

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&)
Reputation Points: 40
Solved Threads: 24
Junior Poster
SCBWV is offline Offline
125 posts
since Apr 2007
Feb 16th, 2009
0

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

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 () /??
Reputation Points: 10
Solved Threads: 1
Junior Poster
jaasaria is offline Offline
123 posts
since Jul 2007
Feb 17th, 2009
0

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

Hi Jaasaria:

Try:
Call LockWindowUpdate(frmPOS.ListView2.hwnd)
userPriceList1
Call LockWindowUpdate(0&)
Reputation Points: 40
Solved Threads: 24
Junior Poster
SCBWV is offline Offline
125 posts
since Apr 2007
Feb 18th, 2009
0

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

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
Reputation Points: 69
Solved Threads: 19
Junior Poster
samir_ibrahim is offline Offline
155 posts
since Sep 2008
Feb 18th, 2009
0

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

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
Reputation Points: 10
Solved Threads: 1
Junior Poster
jaasaria is offline Offline
123 posts
since Jul 2007
Feb 19th, 2009
0

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

Click to Expand / Collapse  Quote originally posted by jaasaria ...
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.
Reputation Points: 69
Solved Threads: 19
Junior Poster
samir_ibrahim is offline Offline
155 posts
since Sep 2008

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in Visual Basic 4 / 5 / 6 Forum Timeline: VB Project
Next Thread in Visual Basic 4 / 5 / 6 Forum Timeline: vb





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC