Results 1 to 5 of 5

Thread: visual basic run time error 5 class

  1. #1

    Thread Starter
    New Member
    Join Date
    Jan 2011
    Location
    Trichy,Tamil Nadu,India
    Posts
    3

    Exclamation visual basic run time error 5 class

    Dear Friend,

    I'm getting problem in vb class module.I have no idea about class module but i was created class file. When i run my application it showing run time error '5'.

    Any one can help me for this problem.

    In form code:
    Code:
    Dim List As SpdListing
    If KeyCode = vbKeyF2 Then
        DoEvents
        Set List = New SpdListing --> Here i am getting error
            List.Class_Initialize
        With List
            .SpdShowList Me, SpdStyle, SpdStyle.ARow, SpdStyle.ActiveCol, "StyleId", "Style", "Style", Qry = ""
        End With
        
    End If
    
    Class Module Code:
    
    Public Type SpdList
        Frm As Object
        spd As Object
        ARow As Integer
        ACol As Integer
        Field1 As String
        Field2 As String
        TblObj As String
        Qry As String
    End Type
    
    Public Function SpdShowList(CurrentFrm As Object, Currentspd As Object, ARow As Integer, ACol As Integer, Field1 As String, Field2 As String, TblObj As String, Qry As String) As String
    Dim List As SpdList
    With List
    .Frm = CurrentFrm
    .spd = Currentspd
    .ARow = ARow
    .ACol = ACol
    .Field1 = Field1
    .Field2 = Field2
    .TblObj = TblObj
    .Qry = Qry
    Strsql = "Select " & .Field1 & VBA.chr(13) & "," & VBA.chr(13) & .Field2 & VBA.chr(13) & " From " + .TblObj
    If .Qry <> "" Then
        Strsql = Strsql & VBA.chr(13) & " Where " & VBA.chr(13) & .Field1 & VBA.chr(13) & " In(" & .Qry & ")"
    Else
        Strsql = Strsql & VBA.chr(13) & " Where " & .Field1 & "='" & FrmSpdListing.SpdFilter.Text & "&#37;'"
    End If
    End With
    Set SpdRs = New ADODB.Recordset
    SpdRs.Open Strsql, SpdCn, adOpenStatic, adLockReadOnly
    Set FrmSpdListing.SpdGrid.DataSource = SpdRs
    'FrmSpdListing.SpdGrid.Columns(0).Width = 0
    FrmSpdListing.Show
    End Function
    Last edited by si_the_geek; Jan 3rd, 2011 at 06:51 AM. Reason: added Code tags

  2. #2
    Super Moderator si_the_geek's Avatar
    Join Date
    Jul 2002
    Location
    Bristol, UK
    Posts
    41,974

    Re: visual basic run time error 5 class

    Welcome to VBForums

    Thread moved from the 'CodeBank VB6' forum (which is for you to post working code examples, not questions) to the 'VB6 and earlier' forum

  3. #3

    Thread Starter
    New Member
    Join Date
    Jan 2011
    Location
    Trichy,Tamil Nadu,India
    Posts
    3

    Re: visual basic run time error 5 class

    Hi si_the_geek,

    Thanks to inform me. Since i am new person in this fourm. SO can u tell me how to post my question.

    Thanks

  4. #4
    Fanatic Member
    Join Date
    Mar 2009
    Posts
    804

    Re: visual basic run time error 5 class

    Set List = New SpdListing --> Here i am getting error
    List.Class_Initialize
    You don't show the Class_Initialize code, which may be causing the error.
    BTW, the Set statement above causes the Class_Initialize code to be
    executed.

    Also, even if the Class_Initialize code didn't cause an error,
    the line List.Class_Initialize would cause another error, since Class_Initialize
    is private to the class.

  5. #5

    Thread Starter
    New Member
    Join Date
    Jan 2011
    Location
    Trichy,Tamil Nadu,India
    Posts
    3

    Re: visual basic run time error 5 class

    Quote Originally Posted by VBClassicRocks View Post
    You don't show the Class_Initialize code, which may be causing the error.
    BTW, the Set statement above causes the Class_Initialize code to be
    executed.

    Also, even if the Class_Initialize code didn't cause an error,
    the line List.Class_Initialize would cause another error, since Class_Initialize
    is private to the class.
    Thanks it is working.

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