Results 1 to 6 of 6

Thread: late binding [RESOLVED]

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    Nov 2003
    Posts
    1,489

    late binding [RESOLVED]

    i have a sub that takes a tabPage as an argument. a tab page is cleared when a button on that page is clicked.

    with option strict on, I get a cast error even when the sub has NO code in it. what is going on?
    Last edited by Andy; Aug 13th, 2004 at 12:05 PM.

  2. #2
    Your Ad Here! Edneeis's Avatar
    Join Date
    Feb 2000
    Location
    Moreno Valley, CA (SoCal)
    Posts
    7,339
    Post your code and what is the error exactly.

  3. #3

    Thread Starter
    Frenzied Member
    Join Date
    Nov 2003
    Posts
    1,489
    VB Code:
    1. Private Sub tab_25_btnClearAll_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) _
    2.     Handles tab_25_btnClearAll.Click
    3.  
    4.         'Dim ctrl As TabControl = CType(sender, TabControl)
    5.  
    6.         'Client.ClearTabControl(ctrl)
    7.         'tab_25_optNo.Checked = True
    8.  
    9.     End Sub

    the error is :"Specified cast is not allowed.

    here's what's going on: option strict is on. when I hit F5, I get build errors and I chooses 'yes' to continue (I think that's the problem) then, when I click this button, I get the error. Notice that the code inside the routine is commented out. the error highlights the sub declaration section.

  4. #4
    yay gay PT Exorcist's Avatar
    Join Date
    Apr 2002
    Location
    . . . my reason of shame
    Posts
    2,729
    NEVER continue with build errors. It's just not worth..
    \m/\m/

  5. #5
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083
    Try DirectCast function instead of Ctype function .

  6. #6
    Your Ad Here! Edneeis's Avatar
    Join Date
    Feb 2000
    Location
    Moreno Valley, CA (SoCal)
    Posts
    7,339
    Originally posted by Pirate
    Try DirectCast function instead of Ctype function .
    Why would that matter? The only difference between the two is CType can work with value and reference types whereas DirectCast only works with reference types.

    What type of control is tab_25_btnClearAll? Is it a button? If so then sender is probably the button and not a tabcontrol hence the error. Although the designer should be picking that up at compile time.

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