CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 5 of 5

Thread: Bang Efficiency

  1. #1
    Join Date
    Aug 2000
    Posts
    265

    Bang Efficiency

    Is the use of the bang when referencing a field name efficient?

    strOldFirst = rstEmployees!fname



  2. #2
    Join Date
    Jan 2000
    Location
    Olen, Belgium
    Posts
    2,477

    Re: Bang Efficiency

    It is as efficient as

    strOldFirst = rstEmployees("fname")
    strOldFirst = rstEmployees.fields!fname
    strOldFirst = rstEmployees.fields("fname")
    strOldFirst = rstEmployees.fields("fname").value



    cause eventually, when compiled, it all looks the same
    however, using the index number instead of the name will be faster, but less flexible when the recordset changes (like fields swapping place and stuff)

    strOldFirst = rstEmployees.Fields(0)




    Tom Cannaerts
    [email protected]

    Programming today is a race between software engineers striving to build bigger and better idot-proof programs, and the universe trying to produce bigger and better idiots. So far, the universe is winning -- Rich Cook
    Tom Cannaerts
    email: [email protected]
    www.tom.be (dutch site)

  3. #3
    Join Date
    Aug 2000
    Posts
    265

    Re: Bang Efficiency

    What does the bang actually do? Why use it?


  4. #4
    Join Date
    May 2000
    Location
    New York, NY, USA
    Posts
    2,878

    Re: Bang Efficiency

    rs.(0)
    rs("Customer_Code")
    rs.fields(0)
    rs.fields("Customer_Code")
    rs.fields.item(0)
    rs.fields.item("Customer_Code")

    In VBScript, the versions that use field indexes instead of names are faster and the extended syntax-rs.fields.
    item(0)-is fastest. The reason: Although VBScript, like VB, supports default properties, VBScript doesn't
    have to search manually for the default property of the object being referenced.


    'undocumented feature
    with rs
    .collect(fld1)
    .collect(fld2)
    end with


    works 30% faster then rs!Field

    Iouri Boutchkine
    [email protected]
    Iouri Boutchkine
    [email protected]

  5. #5
    Join Date
    Jan 2000
    Location
    Olen, Belgium
    Posts
    2,477

    Re: Bang Efficiency

    don't know actually, I only know it can be used for reffering fields in a collection, don't even know if it can be used for all collections, or if it's only for recordsets

    Tom Cannaerts
    [email protected]

    Programming today is a race between software engineers striving to build bigger and better idot-proof programs, and the universe trying to produce bigger and better idiots. So far, the universe is winning -- Rich Cook
    Tom Cannaerts
    email: [email protected]
    www.tom.be (dutch site)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured