|
-
May 27th, 2001, 03:11 PM
#1
Thread Starter
Lively Member
Why does his happen?!
I get a type mismatch error when this occurs:
Private Sub Form_Load()
bActiveSession = False
hOpen = 0
hConnection = 0
optBin.Value = 1
dwType = FTP_TRANSFER_TYPE_BINARY
Dim imgI As ListImage
Set imgI = ImageList1.ListImages.Add(, "open", LoadPicture("open.bmp"))
Set imgI = ImageList1.ListImages.Add(, "closed", LoadPicture("closed.bmp"))
Set imgI = ImageList1.ListImages.Add(, "leaf", LoadPicture("leaf.bmp"))
Set imgI = ImageList1.ListImages.Add(, "root", LoadPicture("root.bmp"))
TreeView1.ImageList = ImageList1
TreeView1.Style = tvwTreelinesPictureText
EnableUI (False)
End Sub
The bolded line is where the error occurs. The thing is, I don't understand it cuz the image is what it is meant to be, and the code and images work somewhere else!!! so why not here? the image is in the right place and is right type etc, but i get this error>?
pls help!
Bob
-
May 27th, 2001, 03:39 PM
#2
_______
<?>
..it's because things are loading and not yet loaded..
move the code to the Form Acitvate and it will work.
"A myth is not the succession of individual images,
but an integerated meaningful entity,
reflecting a distinct aspect of the real world."
___ Adolf Jensen
-
May 27th, 2001, 03:47 PM
#3
Thread Starter
Lively Member
what u mean?
what do u mean the form activate???
thanks, Bob
-
May 27th, 2001, 03:58 PM
#4
PowerPoster
This bit (Private Sub Form_Load() ) is kind of a give away. Cut/paste the code into the Form_Activate event instead of as it currently is the Form_Load event.
-
May 27th, 2001, 04:02 PM
#5
Frenzied Member
Nah, that's not the problem: there is no "image.bmp", the least you can do is give it "C:\image.bmp". There's a good way toget your program's path with a "\" at the end of it, here it is:
MyPath = App.Path & IIf(Right(App.Path,1) = "\", "", "\") & "image.bmp"
That should work, the image's path is now MyPath
-
May 27th, 2001, 04:47 PM
#6
Thread Starter
Lively Member
i think u've missed the points guys...
If i remove the images it says, object required, thats when it can't find the image.
But this is where it is finding the image, but saying there is a type mismatch. The exact same code works elsewhere, so it isn't how I am showing the path, or where the code is...
Thanks,
Bob
-
May 28th, 2001, 09:13 AM
#7
Frenzied Member
Try looking at VB help on LoadPicture, ImageList and Type Mismatch Error
-
May 28th, 2001, 02:53 PM
#8
Thread Starter
Lively Member
Ok...
I think it must be the way that it is loaded. This is because i have had a new project with just the form that has the error in, and it works just fine. When I put it into an MDI, and it is not the loaded form, it doesn't work and gives the type mismatch error.
It can find the images.
In terms of loading i have tried using form activate and for initialize, neither worked.
Lastly, I even loaded the images into the image list in design time and assigned it to the tree view, but the error occured (same one) when it tried to fill the tree nodes.
Can anyone think of anything, this is important!!!
Thanks,
Bob
-
May 29th, 2001, 12:10 PM
#9
Thread Starter
Lively Member
Please
Please help!!! this is urgentish
thanks.
Bob
-
May 29th, 2001, 02:02 PM
#10
Frenzied Member
Why don't you use an array of pictureboxes or images instead of an imagelist?
-
May 29th, 2001, 02:16 PM
#11
Thread Starter
Lively Member
I'm not sure
how exactly to do that, only ever attached an image list to a treeview.. how would I do that, any code?? Thanks you for any of your help 
Bob
-
May 29th, 2001, 02:48 PM
#12
Thread Starter
Lively Member
I'm not sure
how exactly to do that, only ever attached an image list to a treeview.. how would I do that, any code?? Thanks you for any of your help 
Bob
-
May 29th, 2001, 03:15 PM
#13
Member
I ran into the same problem before and couldn't figure out why it was happening I think their was a problem with the code someplace else. However I found away around the problem by putting the code into it's own sub routine.
ex.
ImageList
Private Sub ImageList()
Set imgI = ImageList1.ListImages.Add(, "open", dPicture"open.bmp"))
end sub
-
May 29th, 2001, 03:30 PM
#14
Thread Starter
Lively Member
:(:(:(
No that didn't work either, this is such a weird error, because it doesn't make any sense! How can some code and images work at one point and then (without being altered) they are moved and don't work...I don't know...
Anymore ideas???
thanks,
Bob
-
May 29th, 2001, 03:55 PM
#15
Hyperactive Member
Something has to be up with the imgI variable - try right clicking on the imgI variable name in "Set imgI = ImageList1.List....", then goto Definition, it should take you to the line of code that defines imgI. Either that, or do a search for all instances of imgI in your project, and make sure that it isn't defined globally else where. It shouldn't matter if you have the Dim statement right there, but I have seen some stange stuff with variable names before in VB. You could also try renaming the variable to something completely different ("MyTestVar" for example), just don't do a global search and replace, or you may repeat the same problem.
And your sure that you have:
Dim imgI As ImageList
and not:
Dim imgI As ListImage
I have done this before too....
-
May 29th, 2001, 04:03 PM
#16
Thread Starter
Lively Member
:(
Tried it all but none of it worked 
This is really frustrating cuz it should work right? Just because I've ported one form and images into a MDI doesn't mean it should not work?!
Ne ideas left
Thanks,
Bob
-
May 29th, 2001, 04:27 PM
#17
Hyperactive Member
I played around with this and I can reproduce your problem, but I can't figure out why...must be a vb bug.
For the code that you listed, you don't need to use the Set statment (which is what is causing the problem). If you use the following code, it should work, but I don't know why your (and I) were having problems with the code as you posted it.
Code:
Private Sub Form_Load()
bActiveSession = False
hOpen = 0
hConnection = 0
optBin.Value = 1
dwType = FTP_TRANSFER_TYPE_BINARY
Call ImageList1.ListImages.Add(, "open", LoadPicture("open.bmp"))
Call ImageList1.ListImages.Add(, "closed", LoadPicture("closed.bmp"))
Call ImageList1.ListImages.Add(, "leaf", LoadPicture("leaf.bmp"))
Call ImageList1.ListImages.Add(, "root", LoadPicture("root.bmp"))
TreeView1.ImageList = ImageList1
TreeView1.Style = tvwTreelinesPictureText
EnableUI (False)
End Sub
-
May 29th, 2001, 05:10 PM
#18
Thread Starter
Lively Member
Private Sub FillTreeViewControl(strParentKey As String)
Dim nodX As Node
Dim strImg As String
Dim nCount As Integer, i As Integer
Dim nAttr As Integer
Dim strItem As String
Dim strserver
If EnumItemNameBag.Count = 0 And strParentKey = "events-email.co.uk" Then
Set nodX = TreeView1.Nodes.Add(, tvwFirst, "events-email.co.uk", "events-email.co.uk", "root")
Exit Sub
End If
nCount = EnumItemAttributeBag.Count
If nCount = 0 Then Exit Sub
For i = 1 To nCount
nAttr = EnumItemAttributeBag.Item(i)
strItem = EnumItemNameBag(i)
If nAttr = FILE_ATTRIBUTE_DIRECTORY Then
strImg = "closed"
Else
strImg = "leaf"
End If
Set nodX = TreeView1.Nodes.Add(strParentKey, tvwChild, strParentKey & "/" & strItem, strParentKey & "/" & strItem)
Next
nodX.EnsureVisible
End Sub
OK!!!!!! Now this really is driving me crazy!!!!!!!!!! Now in this part of the code (the bold bit) i get a mismatch!!!!!!!!!!! Why!!!!!!!!!!!! This is sending me so mad!
But at least the form loads now thanks to techman
Thanks for ne more help
Bob
-
May 29th, 2001, 09:21 PM
#19
Hyperactive Member
There is obvously something funny about assigning an object to a variable from a MDI form. You may try moving the code to a routine in a Module, then call it from the form ???
I haven't tried this, but it may help....
-
May 29th, 2001, 09:41 PM
#20
Fanatic Member
just a basic point
sorry to mention this but you have set the treeveiw style property to this havnt you
treeview1.style = 7
you prolly have got it set but i just thought i would mention it
-
May 30th, 2001, 04:51 AM
#21
Frenzied Member
Hey! Why don't you have a look at MSDN Library? I know they have an example on that
-
May 30th, 2001, 06:16 AM
#22
Thread Starter
Lively Member
ok
I have set the type to 7 for the treeview yeah, it SHOULD all work very easily but still, I don't understand!
Ne more ideas welcome
Bob
-
May 30th, 2001, 06:40 AM
#23
Fanatic Member
Code:
TreeView1.Nodes.Add , tvwFirst, "events-email.co.uk", "events-email.co.uk", "root"
Crispin
VB6 ENT SP5
VB.NET
W2K ADV SVR SP3
WWW.BLOCKSOFT.CO.UK
[Microsoft Basic: 1976-2001, RIP]
-
May 30th, 2001, 09:06 AM
#24
Thread Starter
Lively Member
:(
That didn't work either, gave a syntax error, needs those brackets think,
neone else, this is really frustrating!!!!!!!
cheers,
Bob
-
May 30th, 2001, 09:44 AM
#25
Hyperactive Member
Set??
As Techman said in earlier reply, on the first problem, have you tried without the "set" ?
Just a suggestion, have not tried it myself yet.
Set nodX = TreeView1.Nodes.Add(, tvwFirst, "events-email.co.uk", "events-email.co.uk", "root")
Code:
nodX = TreeView1.Nodes.Add(, tvwFirst, "events-email.co.uk", "events-email.co.uk", "root")
Onerrorgoto
Dont be to optimistic, the light at the end of the tunnel might be a train
-
May 30th, 2001, 12:06 PM
#26
Thread Starter
Lively Member
Doh
Sorry i have tested that it says now:
Run time error 91
object variable or with block variable not set
arrrrrrrrrghhhhhhhh
from one error to another!!!
Ne more ideas please?
Thank you!
Bob
-
May 30th, 2001, 02:00 PM
#27
Hyperactive Member
I am not sure if this will make a difference, but how are you showing the MDI Child Form ???
If the form name is Form2 with the MDIChild property set to true, are you showing it like this:
or this:
Code:
Dim MyNewMDIChild As Form
Set MyNewMDIChild = New Form2
MyNewMDIChild.Show
Try the opposite one of however you are declaring the form, and see if it makes a difference. I was able to reproduce your problem the other day, but today I can't seem to, so I couldn't verify if it did anything.
-
May 30th, 2001, 03:19 PM
#28
Thread Starter
Lively Member
:(
No that didnt work either, thanks for the suggestion though
I have no idea why this should give errors...
doesnt make sense!
thanks for ne more suggestions,
Bob
-
May 30th, 2001, 03:37 PM
#29
Member
I ran into the same problem before and couldn't figure out why it was happening I think their was a problem with the code someplace else. However I found away around the problem by putting the code into it's own sub routine.
ex.
ImageList
Private Sub ImageList()
Set imgI = ImageList1.ListImages.Add(, "open", dPicture"open.bmp"))
end sub
****You said that the code works someplace else. Try putting the ImangeList() under the code that's working. Don't know if this is going to work. ******
-
May 30th, 2001, 04:01 PM
#30
Thread Starter
Lively Member
I've done this
Didn't you post early on with this suggestion too? But I have tried it and it doesn't make any difference unfortunatly And the error is in a different place now anyway... when it tries to fill the tree view, it gives the type mismatch
Thanks for the suggestion tho,
ne more welcome,
Bob
-
May 30th, 2001, 04:03 PM
#31
Thread Starter
Lively Member
Just realised
When I said the code worked someplace else, I meant it worked when it was in a seperate project on its own... Not someplace else in the form, hope there wasn't any confusion there
Thanks,
Bob
-
May 30th, 2001, 05:57 PM
#32
Thread Starter
Lively Member
Nemore help?!
Please if anyone has any ideas?
thanks,
Bob
-
May 31st, 2001, 03:42 AM
#33
Frenzied Member
Have you tried selecting the imagelist and pressing F1? I know VB's help has a demo on this.
-
May 31st, 2001, 09:11 AM
#34
Hyperactive Member
can you post the project files, so that we can look at them ???
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
|