Results 1 to 34 of 34

Thread: Why does his happen?!

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Feb 2001
    Location
    England
    Posts
    65

    Arrow 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

  2. #2
    _______ HeSaidJoe's Avatar
    Join Date
    Jun 1999
    Location
    Canada
    Posts
    3,946

    <?>

    ..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

  3. #3

    Thread Starter
    Lively Member
    Join Date
    Feb 2001
    Location
    England
    Posts
    65

    what u mean?

    what do u mean the form activate???

    thanks, Bob

  4. #4
    PowerPoster
    Join Date
    Jul 1999
    Posts
    5,923
    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.

  5. #5
    Frenzied Member Jotaf98's Avatar
    Join Date
    Jun 2000
    Location
    I'm not gonna give you my IP address! Ok... Portugal, South-Western Europe, 3rd rock from the sun (our star is easy to find, a 47 Ursae Majoris in the Milky Way :p )
    Posts
    1,457
    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
    Code:
    Temp = Me.GetIQ()
    'Error 9: Overflow
    'DON'T PANIC! :eek:

    To learn how to use realistic effects in your games like fire, rain, snow and magic effects, read my article on particles systems here.


    Jotaf's Theories!
    "Cats land on their feet. Toast lands peanut butter side down. A cat with toast strapped to its back will hover above the ground in a state of quantum indecision."

  6. #6

    Thread Starter
    Lively Member
    Join Date
    Feb 2001
    Location
    England
    Posts
    65

    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

  7. #7
    Frenzied Member Jotaf98's Avatar
    Join Date
    Jun 2000
    Location
    I'm not gonna give you my IP address! Ok... Portugal, South-Western Europe, 3rd rock from the sun (our star is easy to find, a 47 Ursae Majoris in the Milky Way :p )
    Posts
    1,457
    Try looking at VB help on LoadPicture, ImageList and Type Mismatch Error
    Code:
    Temp = Me.GetIQ()
    'Error 9: Overflow
    'DON'T PANIC! :eek:

    To learn how to use realistic effects in your games like fire, rain, snow and magic effects, read my article on particles systems here.


    Jotaf's Theories!
    "Cats land on their feet. Toast lands peanut butter side down. A cat with toast strapped to its back will hover above the ground in a state of quantum indecision."

  8. #8

    Thread Starter
    Lively Member
    Join Date
    Feb 2001
    Location
    England
    Posts
    65

    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

  9. #9

    Thread Starter
    Lively Member
    Join Date
    Feb 2001
    Location
    England
    Posts
    65

    Please

    Please help!!! this is urgentish

    thanks.
    Bob

  10. #10
    Frenzied Member Jotaf98's Avatar
    Join Date
    Jun 2000
    Location
    I'm not gonna give you my IP address! Ok... Portugal, South-Western Europe, 3rd rock from the sun (our star is easy to find, a 47 Ursae Majoris in the Milky Way :p )
    Posts
    1,457
    Why don't you use an array of pictureboxes or images instead of an imagelist?
    Code:
    Temp = Me.GetIQ()
    'Error 9: Overflow
    'DON'T PANIC! :eek:

    To learn how to use realistic effects in your games like fire, rain, snow and magic effects, read my article on particles systems here.


    Jotaf's Theories!
    "Cats land on their feet. Toast lands peanut butter side down. A cat with toast strapped to its back will hover above the ground in a state of quantum indecision."

  11. #11

    Thread Starter
    Lively Member
    Join Date
    Feb 2001
    Location
    England
    Posts
    65

    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

  12. #12

    Thread Starter
    Lively Member
    Join Date
    Feb 2001
    Location
    England
    Posts
    65

    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

  13. #13
    Member
    Join Date
    Feb 2001
    Location
    Clifton Park, NY
    Posts
    42
    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

  14. #14

    Thread Starter
    Lively Member
    Join Date
    Feb 2001
    Location
    England
    Posts
    65

    :(:(:(

    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

  15. #15
    Hyperactive Member techman2553's Avatar
    Join Date
    Mar 2001
    Location
    <- To your left.
    Posts
    362
    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....
    ----------

  16. #16

    Thread Starter
    Lively Member
    Join Date
    Feb 2001
    Location
    England
    Posts
    65

    :(

    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

  17. #17
    Hyperactive Member techman2553's Avatar
    Join Date
    Mar 2001
    Location
    <- To your left.
    Posts
    362
    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
    ----------

  18. #18

    Thread Starter
    Lively Member
    Join Date
    Feb 2001
    Location
    England
    Posts
    65
    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

  19. #19
    Hyperactive Member techman2553's Avatar
    Join Date
    Mar 2001
    Location
    <- To your left.
    Posts
    362
    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....
    ----------

  20. #20
    Fanatic Member rudvs2's Avatar
    Join Date
    Mar 2001
    Location
    NZ
    Posts
    935

    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

  21. #21
    Frenzied Member Jotaf98's Avatar
    Join Date
    Jun 2000
    Location
    I'm not gonna give you my IP address! Ok... Portugal, South-Western Europe, 3rd rock from the sun (our star is easy to find, a 47 Ursae Majoris in the Milky Way :p )
    Posts
    1,457
    Hey! Why don't you have a look at MSDN Library? I know they have an example on that
    Code:
    Temp = Me.GetIQ()
    'Error 9: Overflow
    'DON'T PANIC! :eek:

    To learn how to use realistic effects in your games like fire, rain, snow and magic effects, read my article on particles systems here.


    Jotaf's Theories!
    "Cats land on their feet. Toast lands peanut butter side down. A cat with toast strapped to its back will hover above the ground in a state of quantum indecision."

  22. #22

    Thread Starter
    Lively Member
    Join Date
    Feb 2001
    Location
    England
    Posts
    65

    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

  23. #23
    Fanatic Member crispin's Avatar
    Join Date
    Aug 2000
    Location
    2 clicks west of a Quirkafleeg...Cornwall, England
    Posts
    754
    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]

  24. #24

    Thread Starter
    Lively Member
    Join Date
    Feb 2001
    Location
    England
    Posts
    65

    :(

    That didn't work either, gave a syntax error, needs those brackets think,

    neone else, this is really frustrating!!!!!!!

    cheers,
    Bob

  25. #25
    Hyperactive Member onerrorgoto's Avatar
    Join Date
    Aug 1999
    Location
    Sweden
    Posts
    330

    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

  26. #26

    Thread Starter
    Lively Member
    Join Date
    Feb 2001
    Location
    England
    Posts
    65

    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

  27. #27
    Hyperactive Member techman2553's Avatar
    Join Date
    Mar 2001
    Location
    <- To your left.
    Posts
    362
    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:

    Code:
    Form2.Show
    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.
    ----------

  28. #28

    Thread Starter
    Lively Member
    Join Date
    Feb 2001
    Location
    England
    Posts
    65

    :(

    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

  29. #29
    Member
    Join Date
    Feb 2001
    Location
    Clifton Park, NY
    Posts
    42
    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. ******

  30. #30

    Thread Starter
    Lively Member
    Join Date
    Feb 2001
    Location
    England
    Posts
    65

    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

  31. #31

    Thread Starter
    Lively Member
    Join Date
    Feb 2001
    Location
    England
    Posts
    65

    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

  32. #32

    Thread Starter
    Lively Member
    Join Date
    Feb 2001
    Location
    England
    Posts
    65

    Nemore help?!

    Please if anyone has any ideas?

    thanks,
    Bob

  33. #33
    Frenzied Member Jotaf98's Avatar
    Join Date
    Jun 2000
    Location
    I'm not gonna give you my IP address! Ok... Portugal, South-Western Europe, 3rd rock from the sun (our star is easy to find, a 47 Ursae Majoris in the Milky Way :p )
    Posts
    1,457
    Have you tried selecting the imagelist and pressing F1? I know VB's help has a demo on this.
    Code:
    Temp = Me.GetIQ()
    'Error 9: Overflow
    'DON'T PANIC! :eek:

    To learn how to use realistic effects in your games like fire, rain, snow and magic effects, read my article on particles systems here.


    Jotaf's Theories!
    "Cats land on their feet. Toast lands peanut butter side down. A cat with toast strapped to its back will hover above the ground in a state of quantum indecision."

  34. #34
    Hyperactive Member techman2553's Avatar
    Join Date
    Mar 2001
    Location
    <- To your left.
    Posts
    362
    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
  •  



Click Here to Expand Forum to Full Width