Results 1 to 6 of 6

Thread: how to avoid late binding ?

  1. #1

    Thread Starter
    Lively Member Edilson's Avatar
    Join Date
    Aug 2000
    Location
    Orlando
    Posts
    81

    how to avoid late binding ?

    Is there a way to early bind the sender object from a mousemove event ?
    when i use Option Strict On I receive Error message in " sender.Left"

  2. #2
    Your Ad Here! Edneeis's Avatar
    Join Date
    Feb 2000
    Location
    Moreno Valley, CA (SoCal)
    Posts
    7,339
    No. The parameter is of the type Object so you can't change it but you can cast it to whatever you think it is inside the event. Just use CType to cast it to a strong type and assign it to a local variable.
    VB Code:
    1. Dim ctrl As Control=CType(sender,Control)
    2. 'ctrl.Left

  3. #3

    Thread Starter
    Lively Member Edilson's Avatar
    Join Date
    Aug 2000
    Location
    Orlando
    Posts
    81
    It works ! Thanks

    But each way will my app work faster ?? Late or early binding?
    iether way at runtime it will have to do the cast , right ??

  4. #4
    yay gay PT Exorcist's Avatar
    Join Date
    Apr 2002
    Location
    . . . my reason of shame
    Posts
    2,729
    early binding turns all that you do later faster and cleaner..it helps you too with the exceptions etc
    \m/\m/

  5. #5
    Your Ad Here! Edneeis's Avatar
    Join Date
    Feb 2000
    Location
    Moreno Valley, CA (SoCal)
    Posts
    7,339
    Yes early binding is always faster although I don't think the difference is as great in .NEt as it was in VB6. But in the case of events there is nothing you can do about it since the event signature must match the event delegate in the object.

  6. #6

    Thread Starter
    Lively Member Edilson's Avatar
    Join Date
    Aug 2000
    Location
    Orlando
    Posts
    81
    It's always an honor to learn from you guys !!

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