Advertisement

07.01.2008 at 04:42AM PDT, ID: 23529758
[x]
Attachment Details

Any performance problems using ByRef when passing an object over to a sub?

Asked by bhermer in Microsoft Visual Basic.Net

Tags:

Hi,

I have a question about the performace issue of byref. I have a senerio where I want to pass a dynamic datagrid and an SQL data reader over to a sub using ByRef. The reason for this is for code reuse, I have up to 30 dynamic grids to process and 30 data readers.

By making my code more readable for myself, am i getting a performance penalty? would i be better expressing it as a prodedural type script of say 800 lines, or reuse with byref and get my code down to about 40 lines?

Speed is critical in this application.

A simplified example written to demonstrate, not real code.


Sub1()

For i = 0 to 30
            Dim tGrid As DataGridView
            tGrid = GetControlByName("grd" & UpdateReader("LeagueID"))
            GameReader = createreader("SELECT * FROM Games WHERE LeagueID='" & UpdateReader("LeagueID") & "'")
            GameReader.Read()
            Sub2(tGrid,(i*7),GameReader)
Next i

End Sub


Sub2 (ByRef tGrid as DataGridView,ByVal ColumnOffset as integer,ByRef tReader as SQLDataReader)
'###  large amount or processing and data manipulation on grid
        tGrid.Rows(0).Cells(1+CellOffSet).Value = tReader ("A Value")

End SubStart Free Trial
 
Keywords: Any performance problems using ByR…
 
Loading Advertisement...
 
[+][-]07.01.2008 at 05:48AM PDT, ID: 21907192

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zone: Microsoft Visual Basic.Net
Tags: ByRef
Sign Up Now!
Solution Provided By: jcoehoorn
Participating Experts: 2
Solution Grade: A
 
 
[+][-]07.01.2008 at 06:07AM PDT, ID: 21907355

Assisted solutions are selected by the member who asked the question as a comment that contributed to their question's solution.

Start your 7-day free trial to view this Assisted Solution or ask the Experts your question.

 
[+][-]07.02.2008 at 04:30AM PDT, ID: 21915186

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
 
Loading Advertisement...
20080716-EE-VQP-32 / EE_QW_EXPERT_20070906