Results 1 to 3 of 3

Thread: Working with Objects

  1. #1

    Thread Starter
    Fanatic Member SeaHag's Avatar
    Join Date
    Jul 2001
    Location
    Lake Huron
    Posts
    901

    Working with Objects

    Why does this give me a runtime error 424 ... object required


    VB Code:
    1. Public Sub Opt(chkbox As CheckBox)
    2. If chkbox.Value = False Then
    3.     chkbox.Caption = "Add"
    4. ElseIf chkbox.Value = True Then
    5.     chkbox.Caption = "Option"
    6. End If
    7.  
    8. End Sub

    Seahag

  2. #2
    Retired VBF Adm1nistrator plenderj's Avatar
    Join Date
    Jan 2001
    Location
    Dublin, Ireland
    Posts
    10,359
    This works for me ...

    VB Code:
    1. Option Explicit
    2.  
    3.  
    4. Public Sub Opt(chkbox As CheckBox)
    5.     If Not chkbox.Value = 0 Then
    6.         chkbox.Caption = "Box was not ticked"
    7.     Else
    8.         chkbox.Caption = "Box was ticked"
    9.     End If
    10. End Sub
    11.  
    12.  
    13. Private Sub CheckBox1_Click()
    14.     Opt CheckBox1
    15. End Sub
    Microsoft MVP : Visual Developer - Visual Basic [2004-2005]

  3. #3
    Frenzied Member mlewis's Avatar
    Join Date
    Sep 2000
    Posts
    1,226
    Are you passing it a true object box?

    Also, at the beginning of the code where that routine is (form/module/etc) put this line if its not already there:

    Option Explicit

    This will help debug your code.
    M. Lewis
    Pi-Q Software
    How many mouse clicks does it take to cook breakfast?

    Blargh! I am dead!

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