Results 1 to 16 of 16

Thread: problem only when running .exe doesn't appear in debug

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Sep 1999
    Location
    u.s.a
    Posts
    127

    Unhappy

    Hy all.
    Long time no see...

    I don't understand how I can have a problem that doesn't appear when I step through my program in debug mode and does appear when I run the EXE file.

    I keep getting an error message only in the exe program:
    "object variable or with block variable not set"
    run time error 91.

    Is this a known problem that only occurs when running the exe file?

    I have changed the enviroment version from vb5 to vb6.
    could that be the cause of the problem???

    I have traced the problem to this code:

    'cur_cb is ither a combobox or a listbox
    Public Function combo_list(cur_cb As Control, Optional text_str)

    Dim found As Integer
    If IsMissing(text_str) Then
    check_test = cur_cb.Text
    Else
    check_test = text_str
    End If

    For i = 0 To cur_cb.ListCount - 1
    If check_test = cur_cb.List(i) Then
    found = 1
    Exit For
    End If
    Next

    If found = 1 Then
    combo_list = i + 1
    Else
    combo_list = -1
    End If

    End Function

    If anybody could spot out an obvious problem I would be gratefull...

    Thanks.
    Dan.



  2. #2
    Lively Member
    Join Date
    Jun 2000
    Posts
    82

    Question

    Hi Dan

    I've had a similar problem, but not with combo or list boxes. It seems to be something to do with timing. Some variable hasn't been set yet, which has been in the interpreted version as it's slower. Try to avoid DoEvents commands in the rest of your code, as for your sample, it seems fine. This is basically the same, and it seems to work in compiled and interpreted versions, so I'd say the problem lies elsewhere.

    Public Function Combo_List(Cur_CB As Control, Optional Text_Str)

    Dim Found As Integer
    Dim Check_Test As String

    If Text_Str = "" Then
    Check_Test = Cur_CB.Text
    Else
    Check_Test = Text_Str
    End If

    Combo_List = -1

    For i = 0 To Cur_CB.ListCount - 1
    If Check_Test = Cur_CB.List(i) Then
    Combo_List = i + 1
    End If
    Next

    End Function

  3. #3
    Member
    Join Date
    Jul 1999
    Location
    J-ville, NC
    Posts
    54
    Which line is highlighted when you press debug?
    David Underwood
    Cannabatech Corporation

    ICQ - 14028049
    E-mail - [email protected]

    AIM - DK4ever23[/b]


  4. #4

    Thread Starter
    Lively Member
    Join Date
    Sep 1999
    Location
    u.s.a
    Posts
    127
    Andrew,
    Thanks for the prompt replay.
    I don't have any DoEvents call in my program, so that can't be the problem.
    I made an error trap wich made a msgbox pop up in the function I added to my original post so that I could view the info I wanted about the problem in the exe version.
    For some reasone the list box methods aren't recodnized.
    The Cur_CB.ListCount crashes the function and so does the
    Cur_CB.List(i) .
    (finding this out after many changes to the code to filter the problem).
    Any Ideas why the function does not recodnize these methods?
    (inly in the exe ofcourse...)

    Thanks.
    Dan.

  5. #5
    Lively Member
    Join Date
    Jun 2000
    Posts
    82
    Does the Cur_CB.Text crash as well? (Have you tried calling the function with no Text_Str?)

  6. #6
    Guest
    In your quick list. are any of the properties or methods repeated. I have run into that problem with some controls making additions to older programs.(particulary with list views)




  7. #7

    Thread Starter
    Lively Member
    Join Date
    Sep 1999
    Location
    u.s.a
    Posts
    127

    Thumbs up

    BG,
    I don't know what you mean by "repeated properties".
    But it seems you know the problem.
    How did you resolve it?
    I have a feeling it has to do with the version change of vb5 to vb6.

    Andrew,
    all methods ,and even the mentioning of cur_cb with out a method crashes the function.

    for some reasone the function can't accept the listbox as a parameter although it runs till trying to activate a method of the listbox.

    Why does this hapen only in the exe file?

    Trying to stay sane.
    Dan.

  8. #8
    Former Admin/Moderator MartinLiss's Avatar
    Join Date
    Sep 1999
    Location
    San Jose, CA
    Posts
    33,431
    I think your problem is that you seem to not have dimensioned check_test and other variables. The VB IDE is more forgiving than an EXE. You should also dimension the function like

    Public Function combo_list(cur_cb As Control, Optional text_str) As Integer

  9. #9

    Thread Starter
    Lively Member
    Join Date
    Sep 1999
    Location
    u.s.a
    Posts
    127
    Martin,
    I have many functions with undimentioned variables.
    Why should this one be any different.
    Could it be that sending a listbox as a parameter,together with not dimentioning some veriables causes an error?!?

    I will try it out anyway....

    Thanks.
    Dan.

    [email protected]

  10. #10
    Former Admin/Moderator MartinLiss's Avatar
    Join Date
    Sep 1999
    Location
    San Jose, CA
    Posts
    33,431
    I suggest that you always use Option Explicit. Without it it may take some time to figure out why, for example, the following MsgBox displays a blank rather than "100".

    Code:
        For x = 1 To 100
            NotObvious = NotObvious + 1
        Next
        
        MsgBox Not0bvious

  11. #11
    Guest
    I'm still not sure this is the same prob I had but I kept getting the same error. I had to remove my list and add it again. What I meat by the methods repeating was, say I typed in "list1 " then"." in my quick list all of the properties and methods were listed twice.?.

  12. #12
    Lively Member
    Join Date
    Mar 2000
    Posts
    103
    you idiot... dimension your variables properly. You haven't dimensioned 'i'... that's where it's dying on you.

  13. #13

  14. #14
    Lively Member
    Join Date
    Mar 2000
    Posts
    103
    Didn't mean to hurt your feelings.

  15. #15
    Addicted Member
    Join Date
    Jan 2000
    Location
    Oshkosh, WI
    Posts
    163

    Talking

    I agree with Jamie_Dowd, except for the idiot part. Option explict should ALWAYS be included. Professionals should never have undimensioned variables !!! Not dimensioning is sloppy and lazy. Alright I'll get off my soapbox.

    danab, I suggest you include Option explicit and then debug your app.
    Glenn D
    Development/Analyst

  16. #16

    Thread Starter
    Lively Member
    Join Date
    Sep 1999
    Location
    u.s.a
    Posts
    127
    Jamie
    (in response to your subtle approach):
    WRONG!!!

    I already dimensioned ‘i’ and I converted everything to option explicit - still doesn't work.

    Even though I agree that "option explicit" is healthy programming don't see how it should have affected this function.


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