Results 1 to 14 of 14

Thread: Object variable or with block variable not set

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Sep 2002
    Posts
    146

    Object variable or with block variable not set

    My program uses only one activeX, which is Ms Interent Control
    shdocvw.dll



    I tested my program (without using P&D) on 10 computers. The thing is that it runs perfectly on 9 computers. But on the last computer, it gives "object varible not set" error.

    I cant seem to locate the line of error.
    The error seems to appear while the form is loading...


    I then tried P&D. It's even worse. My program didn't work on all the computers, including my computer! The same error...



    Code:
    Private Sub Form_Load()
    On Error GoTo hell
    Me.Show
    
    Dim i As Integer
    
    
    'Set CustomWB = New WBCustomizer
    'With CustomWB
         '   .EnableContextMenus = False 'Disable The Menu
         '   .EnableAllAccelerators = True
         '   Set .WebBrowser = WebBrowser1
    'End With
    
    'CustomWB.EnableContextMenus = False
    
    lbltemp.Caption = getDesktopPath
    
    
    Dim Line1 As String
    Dim num As String
    Dim score As String
    
    fileName = lbltemp.Caption & "\Model School System (" + schooltype + ").dat"
    
    
    
    If Dir(fileName) <> "" Then
                Open fileName For Input As #1
                        Do Until EOF(1)
                                Input #1, Line1
                                If Line1 = "#academic" Or Line1 = "#cocur" Then Exit Do
                                num = Left(Line1, InStr(Line1, "#") - 1)
                                element(CInt(num)) = True
                                score = Right(Line1, Len(Line1) - InStr(Line1, "#"))
                                scores(CInt(num)) = score
                                
                                If CInt(num) = 9 Then
                                        element9_count = element9_count + 1
                                        ReDim Preserve element9(1 To element9_count) As String
                                        element9(element9_count) = score
                               End If
                        
                        Loop
                        If Line1 = "#cocur" Then
                                For i = 1 To 5
                                        Input #1, cocur.kelab(i)
                                        Input #1, cocur.badan(i)
                                        Input #1, cocur.sukan(i)
                                        Input #1, cocur.kesel(i)
                                Next i
                                isCocurLoaded = True
                        End If
                       
                        While Not EOF(1)
                                Input #1, Line1
                                If Line1 = "#academic" And schooltype <> "SMK" Then
                                        isAcademicLoaded = True
                                        For i = 1 To 6
                                                Input #1, PKSR(i).a
                                                Input #1, PKSR(i).b
                                                Input #1, PKSR(i).C
                                                Input #1, PKSR(i).D
                                                Input #1, PKSR(i).E
                                                Input #1, PKSR(i).gpt
                                                Input #1, PKSR(i).total
                                        Next i
                                                         
                                        Input #1, UPSR.a
                                        Input #1, UPSR.b
                                        Input #1, UPSR.C
                                        Input #1, UPSR.D
                                        Input #1, UPSR.E
                                        Input #1, UPSR.gpt
                                        Input #1, UPSR.total
                               ElseIf Line1 = "#academic" And schooltype = "SMK" Then
                                        isAcademicLoaded = True
                                        For i = 1 To 3
                                                Input #1, PKSM1(i).a
                                                Input #1, PKSM1(i).b
                                                Input #1, PKSM1(i).C
                                                Input #1, PKSM1(i).D
                                                Input #1, PKSM1(i).E
                                                Input #1, PKSM1(i).gpt
                                                Input #1, PKSM1(i).total
                                        Next i
                                                         
                                        Input #1, PMR.a
                                        Input #1, PMR.b
                                        Input #1, PMR.C
                                        Input #1, PMR.D
                                        Input #1, PMR.E
                                        Input #1, PMR.gpt
                                        Input #1, PMR.total
                                        
                                        For i = 4 To 5
                                            Input #1, PKSM2(i).A1
                                            Input #1, PKSM2(i).A2
                                            Input #1, PKSM2(i).B3
                                            Input #1, PKSM2(i).B4
                                            Input #1, PKSM2(i).C5
                                            Input #1, PKSM2(i).C6
                                            Input #1, PKSM2(i).D7
                                            Input #1, PKSM2(i).E8
                                            Input #1, PKSM2(i).G9
                                            Input #1, PKSM2(i).gpt
                                            Input #1, PKSM2(i).total
                                        Next i
                                        
                                        Input #1, SPM.A1
                                        Input #1, SPM.A2
                                        Input #1, SPM.B3
                                        Input #1, SPM.B4
                                        Input #1, SPM.C5
                                        Input #1, SPM.C6
                                        Input #1, SPM.D7
                                        Input #1, SPM.E8
                                        Input #1, SPM.G9
                                        Input #1, SPM.gpt
                                        Input #1, SPM.total
                                        
                                        For i = 6 To 7
                                                Input #1, PKSM3(i).a
                                                Input #1, PKSM3(i).Am
                                                Input #1, PKSM3(i).Bp
                                                Input #1, PKSM3(i).b
                                                Input #1, PKSM3(i).Bm
                                                Input #1, PKSM3(i).Cp
                                                Input #1, PKSM3(i).C
                                                Input #1, PKSM3(i).Cm
                                                Input #1, PKSM3(i).Dp
                                                Input #1, PKSM3(i).D
                                                Input #1, PKSM3(i).F
                                                Input #1, PKSM3(i).gpt
                                                Input #1, PKSM3(i).total
                                        Next i
                                        
                                        Input #1, STPM.a
                                        Input #1, STPM.Am
                                        Input #1, STPM.Bp
                                        Input #1, STPM.b
                                        Input #1, STPM.Bm
                                        Input #1, STPM.Cp
                                        Input #1, STPM.C
                                        Input #1, STPM.Cm
                                        Input #1, STPM.Dp
                                        Input #1, STPM.D
                                        Input #1, STPM.F
                                        Input #1, STPM.gpt
                                        Input #1, STPM.total
                                        
                                        Input #1, STAM.a
                                        Input #1, STAM.Am
                                        Input #1, STAM.Bp
                                        Input #1, STAM.b
                                        Input #1, STAM.Bm
                                        Input #1, STAM.Cp
                                        Input #1, STAM.C
                                        Input #1, STAM.Cm
                                        Input #1, STAM.Dp
                                        Input #1, STAM.D
                                        Input #1, STAM.F
                                        Input #1, STAM.gpt
                                        Input #1, STAM.total
                                        
                                        
                                End If
                       Wend
                       
                Close #1
    Else
                Open fileName For Append As #1
                Close #1
                'We'r done here
    End If
    
    
    WebBrowser1.Navigate App.Path & "\data\index.htm"
    
    Exit Sub
    hell:
    MsgBox "Sorry, the data file " & fileName & " is damaged. You could try deleting it and running this program again", 16
    End Sub
    Attached Images Attached Images  

  2. #2
    "Digital Revolution"
    Join Date
    Mar 2005
    Posts
    4,471

    Re: Object variable or with block variable not set

    What is WBCustomizer? Is the web browser's ActiveX control registering successfully in the install? Was the WBCustomizer code commented out when you compiled/installed it on the other computers?

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    Sep 2002
    Posts
    146

    Re: Object variable or with block variable not set

    It's commented out, bro..

  4. #4
    "Digital Revolution"
    Join Date
    Mar 2005
    Posts
    4,471

    Re: Object variable or with block variable not set

    Quote Originally Posted by winterslam
    It's commented out, bro..
    Ok...

    Are you using Option Explicit in your code?

    What is cocur, PKSR, STMP, etc?

  5. #5

    Thread Starter
    Addicted Member
    Join Date
    Sep 2002
    Posts
    146

    Re: Object variable or with block variable not set

    Yes I'm using option explicit..



    Those are the UDTs stored in *.bas file


    Code:
    Public Type primary_type
            a As Integer
            b As Integer
            C As Integer
            D As Integer
            E As Integer
           
            gpt As Single
            total As Integer
    End Type
    
    
    Public Type secondary_type
            A1 As Integer
            A2 As Integer
            B3 As Integer
            B4 As Integer
            C5 As Integer
            C6 As Integer
            D7 As Integer
            E8 As Integer
            G9 As Integer
                   
            gpt As Single
            total As Integer
    End Type
    
    
    Public Type preu_type
            a As Integer
            Am As Integer
            Bp As Integer
            b As Integer
            Bm As Integer
            Cp As Integer
            C As Integer
            Cm As Integer
            Dp As Integer
            D As Integer
            F As Integer
            
            total As Integer
            gpt As Single
    
    End Type
    
    Public Type cocur_type
            kelab(1 To 6) As Single
            badan(1 To 6) As Single
            sukan(1 To 6) As Single
            kesel(1 To 6) As Single
            
            peratus_kelab(1 To 5) As Single
            peratus_badan(1 To 5) As Single
            peratus_sukan(1 To 5) As Single
            peratus_kesel(1 To 5) As Single
            gps As Single
            
            count As Integer
    End Type
    
    
    Public PKSR(1 To 6) As primary_type
    Public UPSR As primary_type
    
    Public PKSM1(1 To 3) As primary_type
    Public PMR As primary_type
    
    Public PKSM2(4 To 5) As secondary_type
    Public SPM As secondary_type
    
    Public PKSM3(6 To 7) As preu_type
    Public STPM As preu_type
    Public STAM As preu_type

  6. #6
    "Digital Revolution"
    Join Date
    Mar 2005
    Posts
    4,471

    Re: Object variable or with block variable not set

    It'd help to know what line of code is raising the error.

    The only code that I can think of that would cause it is the code that is commented out, but you said you still got the error with it commented.

    Unless the error isn't happening in Form_Load().

    The only other line that uses an object is the last one: WebBrowser1.Navigate which I highly doubt is causing an error. WebBrowser1 is the web browser control shown in the screen shot, right?

    Sorry, only thing I can think of is the error is being caused by something outside of Form_Load().

  7. #7
    New Member
    Join Date
    Jan 2008
    Posts
    4

    Re: Object variable or with block variable not set

    I have a code which is giving same error mesage when I try to work it. I tried it on 4 computers. Two of them have single core proccessors (a celeron and a pentium4 3.0 (with hyperthreading)); and code has worked properly on them. Other two have dual core processors (a D915 and a E4500), and code has not worked giving the error 91. (I have tried /numproc = 1 or other methods to use just one core, and no method has worked.) Already I wasn't able to find the solution.

  8. #8
    Junior Member
    Join Date
    Feb 2008
    Posts
    21

    Re: Object variable or with block variable not set

    If you run via the designer UI and click Debug when the error occurs that should highlight a line, it sounds like you need to set something like

    Set MyBrowser = New WebBrowser
    or
    set Col = New Collection

    Just a little input from me
    kind regards
    Devon

  9. #9
    Frenzied Member zynder's Avatar
    Join Date
    Nov 2006
    Location
    localhost
    Posts
    1,434

    Re: Object variable or with block variable not set

    Just shooting in the dark here... i know you are using webbrowser control. Can you check the version of Internet explorer to all workstations?

    shdocvw.dll

    I know that there are some issues to IE7 especially if your using IE6 or vice versa on the development.

  10. #10
    New Member
    Join Date
    Jan 2008
    Posts
    4

    Re: Object variable or with block variable not set

    I've written before that I have a code wich is working properly on 2 of 4 computers. It is a DirectX application. I myself set two of the computers and the application working properly on one of them which has a single core processor. I think there is no software difference betwen them. All computers are windows XP installed .

    The project includes just one form.
    There is a referance to 'DirectX 8 for Visual basic Type Library'

    It gives an error on at that line:
    Code:
    D3DDevice.SetTransform D3DTS_WORLD, matWorld
    D3DDevice is declared at the declarations section of the form:
    Code:
    Dim D3DDevice As Direct3DDevice8
    Ans is set in a sub procedure:
    Code:
    Set D3DDevice = D3D.CreateDevice(D3DADAPTER_DEFAULT, DDDEVTYPE_HAL, frmMain.hWnd, BehaviourFlag, D3DWindow)

  11. #11
    PowerPoster
    Join Date
    Jul 2006
    Location
    Maldon, Essex. UK
    Posts
    6,334

    Re: Object variable or with block variable not set

    Winterslam: I'd have thought that removing this line:
    Code:
    On Error GoTo hell
    and running the code would highlight the failing statement.

    HiroReW: I suggest you start your own thread, you're just confusing things (well me, at least) in this one.

  12. #12
    New Member
    Join Date
    Jan 2008
    Posts
    4

    Re: Object variable or with block variable not set

    Doogle:
    I thought that samething parallel between two cases that codes are working on some computers and not working on the others. And the problem may have its source in hardware, but not in software. If someone has any idea about this situation... But you may be right. It may be better if I start a new thread. Thanks.

  13. #13
    New Member
    Join Date
    Jan 2008
    Posts
    4

    Re: Object variable or with block variable not set

    qwert

  14. #14
    Banned randem's Avatar
    Join Date
    Oct 2002
    Location
    Maui, Hawaii
    Posts
    11,385

    Re: Object variable or with block variable not set

    It's your deployment. I would bet that the computers that your code worked on and did not work on had different version of IE installed. IE6 vs IE7... It's a deployment issue...

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