Results 1 to 7 of 7

Thread: Run-Time Error 91... Variable not set

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    Sep 1999
    Location
    Phoenix, az
    Posts
    1,517
    I Have 3 Pictures
    All Variables... StdPictures






    Code:
     
    Option Explicit
    'API
    '
    Private Declare Function BitBlt Lib "gdi32.dll" (ByVal hdcDest As Long, ByVal nXDest As Long, ByVal nYDest As Long, ByVal nWidth As Long, ByVal nHeight As Long, ByVal hdcSrc As Long, ByVal nXSrc As Long, ByVal nYSrc As Long, ByVal dwRop As Long) As Long
    '
    'Types
     Private Type MPicture
       ForeLayer As StdPicture
       Layer2 As StdPicture
        Sprite(10) As StdPicture
        Enbedded As StdPicture
    End Type
    '
    'Variables
    '
    Private ForePicture As MPicture
    Sub Render()
        ConbinePics
    BitBlt FrmTop.Picture, 0, 0, ForePicture.Enbedded.Width, ForePicture.Enbedded.Height, ForePicture.Enbedded.Picture, 0, 0, vbSrcCopy
    End Sub
    
    Private Sub ConbinePics()
        BitBlt ForePicture.Enbedded.Picture, 0, 0, ForePicture.ForeLayer.Width, ForePicture.ForeLayer.Height, ForePicture.ForeLayer.Picture, 0, 0, vbSrcCopy
        BitBlt ForePicture.Enbedded.Picture, 0, 0, ForePicture.Sprite(0).Width, ForePicture.Sprite(0).Height, ForePicture.Sprite(0).Picture, 0, 0, vbSrcCopy
    End Sub
    It puts together images then it
    puts them on the screen ( to the theory
    that I think that will stop the flashing
    and I should have smooth rendering)

    Help?


  2. #2
    Hyperactive Member
    Join Date
    Mar 2000
    Posts
    461
    The error occurs when you have datatypes (ie StdPicture) that require initialization before being able to be used.

    In order to initialize something you need to use a "Set" command... hence the "Variable not Set" occuring.

    There are a few ways of doing this depending on what type of object it is.

    Dim objItem as NEW datatype

    Or with pictures I think there is a way of using the "Set picObject = loadPicture()" to initialize the object.

    Try it

  3. #3
    Guest

    Talking I've told him that...

    YES, you can use SET to set stdpictures.

    I've told you that...

  4. #4
    Hyperactive Member
    Join Date
    Mar 2000
    Posts
    461
    As for it giving you smooth rendering and stop the "flashing" I hate to inform you this but it wont.

    Not even CLOSE.

    The "flashing" is a result of screen updating occuring out of sync with the refresh of the monitor among other things.

    The way "graphics" people get around it is called "double-buffering". They create a second version of the screen with the new positions and then "swap" the screens around, working on the hidden screen and swapping again.

    Unfortunately unless you are specifically using a DirectX screen map or some other graphical method, the standard form display on VB does not allow you to have any of this kind of functionality.

    The flash is there to stay.

  5. #5
    Frenzied Member mlewis's Avatar
    Join Date
    Sep 2000
    Posts
    1,226

    Cool No, its not.

    The flash can be gotten rid of.

    For double-buffering using plain VB forms, you can do this:

    1. Create a hidden picturebox set its AutoRedraw to True
    2. In the refresh code, BitBlt etc onto the picturebox
    3. At the end of the refresh code, BitBlt the picturebox onto the form
    4. Observe your flickering disappear.
    M. Lewis
    Pi-Q Software
    How many mouse clicks does it take to cook breakfast?

    Blargh! I am dead!

  6. #6
    Frenzied Member mlewis's Avatar
    Join Date
    Sep 2000
    Posts
    1,226
    You may want to set the PictureBox to have no border as well.

    Sorry. My oversight.
    M. Lewis
    Pi-Q Software
    How many mouse clicks does it take to cook breakfast?

    Blargh! I am dead!

  7. #7
    Guest

    Wink Great idea.


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