|
-
Apr 8th, 2001, 07:59 PM
#1
Thread Starter
Frenzied Member
I keep getting this runtime error 91..
"Object variable or With block variable not set"
what does it mean?
-
Apr 8th, 2001, 08:05 PM
#2
with what are you getting it, a variable, or control, or what?
Laugh, and the world laughs with you. Cry, and you just water down your vodka.
Take credit, not responsibility
-
Apr 8th, 2001, 08:08 PM
#3
PowerPoster
I usually get that when i haven't set a variable with the Set keyword. For example the DataSource for many controls has to be done like so;
Code:
Set Moo.DataSource = Whatever
If you just put
Code:
Moo.DataSource = Whatever
it moans with that error.
-
Apr 8th, 2001, 08:08 PM
#4
Thread Starter
Frenzied Member
heres my code:
Code:
If TypeOf p_CurControl Is ListView Then
'
'if active control is listview
'
If p_CurItem.Icon = 4 Then
'
'If selected item is folder
'
GetSelectedPath = p_CurNode.Key & "\" & Right$(p_CurItem.Text, Len(p_CurItem.Text) - 1)
Else
'
'if selected item is shortcut
'
GetSelectedPath = p_CurNode.Key & "\" & p_CurItem.Text
End If
Else
'
'If active control is treeview
'
GetSelectedPath = p_CurNode.Key
End If
I get the error at GetSelectedPath = p_CurNode.Key & "\" & p_CurItem.Text
if i try msgbox p_curnode.key, i still get the same error.. This isnt my code, im just messin with someone elses
-
Apr 8th, 2001, 08:08 PM
#5
Addicted Member
This means that you have created a variable that refers to an object, that doesn't exist...
For example:
Code:
Dim fnt As StdFont
Private Sub Form_Load()
Set fnt = New StdFont 'When you leave this line, vb tries to do the next line with 'Nothing'
fnt.Name = "Arial"
End Sub
Code that I author is neither elegant nor efficient. It is, however, functional. Once I get something that works, I'm generally satisfied with myself - I mean, if it works, that's good enough, right?
Originally posted by aknisely
Sorry, but I feel uncomfortable on CC with clothes on
__________________
The truth ... is out there!
-
Apr 9th, 2001, 04:21 AM
#6
You get this if you try to use a variable, but haven't told VB what the variables equal to :
Code:
Dim AString as String
AString = "Hello World"
MsgBox AString
Will work, but in the below, I've just declared the variable, & not set a value to it so VB doesn't know what on earth tho return
(and sorry for using a Hello World example ) :
Code:
Dim AString as String
MsgBox AString
Last edited by alex_read; Apr 9th, 2001 at 05:36 AM.
-
Apr 9th, 2001, 05:01 AM
#7
Addicted Member
Hi toghether !!!
Sorry for my dump question, do you have compiled your project ?
Because this error message happend often to me, if I forgot an "endif, ....", in a with statement.
Note; the rror must not be in the same module
-cu TheOnly
-
Apr 9th, 2001, 05:25 AM
#8
Hyperactive Member
Actually Alex your answer will work, assuming the declaration is a typo ( you missed the 'r' in string). A string is initialised to "" when it's declared so you can use it, it'll just be blank. The error we're talking about here is specific to an object. That's because an object is just a pointer to a block of memory but if it's not set then it literally points at nothing and VB doesn't know what to do. Hence this error. TheOnly's example illustrates the other time you will get this message.
Sooo, one of the objects in the original code must not be set. See my earlier reply to see how to check this out.
Sorry to be a smart arse but I thought you might like to know the above.
Anti-smartie pants note : All variables are actually pointers to a bit of memory where the value is held BUT VB does not initialise an object's memory space for you.
Last edited by Paul Warren; Apr 9th, 2001 at 05:30 AM.
That's Mr Mullet to you, you mulletless wonder.
-
Apr 9th, 2001, 05:33 AM
#9

Point taken, didn't test this one anyway.
with my posts, you can guarantee it's always a typo & I constantly go back into my posts to change words - this is ammended!
-
Apr 9th, 2001, 06:29 AM
#10
-
Apr 9th, 2001, 06:37 AM
#11
Nah, these ones I'm talking about is me going into the already posted answers & ammending them.
-
Apr 9th, 2001, 06:57 AM
#12
Hyperactive Member
Yeah, but RDO stands for Remote Data Objects. + 1
That's Mr Mullet to you, you mulletless wonder.
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
|