|
-
Jun 20th, 2000, 07:46 AM
#1
Thread Starter
Lively Member
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.
-
Jun 20th, 2000, 10:25 AM
#2
Lively Member
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
-
Jun 20th, 2000, 11:58 AM
#3
Member
Which line is highlighted when you press debug?
-
Jun 20th, 2000, 04:49 PM
#4
Thread Starter
Lively Member
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.
-
Jun 21st, 2000, 04:05 AM
#5
Lively Member
Does the Cur_CB.Text crash as well? (Have you tried calling the function with no Text_Str?)
-
Jun 21st, 2000, 04:24 AM
#6
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)
-
Jun 21st, 2000, 05:28 AM
#7
Thread Starter
Lively Member
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.
-
Jun 21st, 2000, 05:44 AM
#8
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
-
Jun 21st, 2000, 08:42 PM
#9
Thread Starter
Lively Member
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] 
-
Jun 21st, 2000, 09:36 PM
#10
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
-
Jun 21st, 2000, 10:33 PM
#11
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.?.
-
Jun 22nd, 2000, 01:14 AM
#12
Lively Member
you idiot... dimension your variables properly. You haven't dimensioned 'i'... that's where it's dying on you.
-
Jun 22nd, 2000, 01:22 AM
#13
Jamie_Dowd: That type of response is not called for.
-
Jun 22nd, 2000, 01:37 AM
#14
Lively Member
Didn't mean to hurt your feelings.
-
Jun 22nd, 2000, 04:37 AM
#15
Addicted Member
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
-
Jun 22nd, 2000, 07:06 AM
#16
Thread Starter
Lively Member
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|