Results 1 to 11 of 11

Thread: [RESOLVED] [HELP!] Stupid Run Time error 91....

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Oct 2009
    Location
    Missouri
    Posts
    770

    Resolved [RESOLVED] [HELP!] Stupid Run Time error 91....

    I searched the forums, and Si's sig about errors with vb6. But didn't help. I have this code:
    Moduel:
    Code:
    Option Explicit
    Public Declare Function BitBlt Lib "gdi32" (ByVal hDestDC As Long, ByVal X As Long, ByVal Y As Long, ByVal nWidth As Long, ByVal nHeight As Long, ByVal hSrcDC As Long, ByVal xSrc As Long, ByVal ySrc As Long, ByVal dwRop As Long) As Long
    Public Declare Function GetAsyncKeyState Lib "user32" (ByVal vKey As Long) As Integer
    Public picRedBrick As PictureBox
    Form1:
    Code:
    Private Sub Command_Click()
    picRedBrick.Picture = VB.LoadPicture(App.Path & "\Brick_Red.bmp")
    Set picRedBrick.ScaleMode = "3"
    BitBlt Form1.hDC, 0, 0, esta.ScaleWidth, esta.ScaleHeight, esta.hDC, 0, 0, vbSrcCopy
    End Sub
    It isn't working, and it highlights both lines that i try to set the scalemode, AND load the picture. Am i doing something wrong?
    Rate my post if i helped you!


    Button Configuration Control For VB6 GetAsyncKeyState
    I'm the 7th best high school programmer in the nation!(according to SkillsUSA Nationals)(Used C#.Net)

  2. #2
    PowerPoster
    Join Date
    Jul 2006
    Location
    Maldon, Essex. UK
    Posts
    6,334

    Re: [HELP!] Stupid Run Time error 91....

    Quote Originally Posted by Gamemaster1494 View Post
    Am i doing something wrong?
    Yes
    Code:
    picRedBrick.Picture = LoadPicture(App.Path & "\Brick_Red.bmp")
    picRedBrick.ScaleMode = 3
    'Set' is used to initialise objects, here you just want to assign a value to a Property of an object, the ScaleMode property is an Integer not string, so "3" would be incorrect.
    Last edited by Doogle; Sep 6th, 2010 at 01:28 AM.

  3. #3

    Thread Starter
    Fanatic Member
    Join Date
    Oct 2009
    Location
    Missouri
    Posts
    770

    Re: [HELP!] Stupid Run Time error 91....

    Okay. I did that and it still highlights it and says the same thing.
    Rate my post if i helped you!


    Button Configuration Control For VB6 GetAsyncKeyState
    I'm the 7th best high school programmer in the nation!(according to SkillsUSA Nationals)(Used C#.Net)

  4. #4
    PowerPoster
    Join Date
    Jul 2006
    Location
    Maldon, Essex. UK
    Posts
    6,334

    Re: [HELP!] Stupid Run Time error 91....

    Ok, I see the problem. You're trying to dynamically create a PictureBox, which , as far as I know you can't do (ie attempting to do: Set picRedBrick = New PictureBox, will not work - you'll get an Invalid use of New Keyword)

    What exactly are you trying to do ?

  5. #5

    Thread Starter
    Fanatic Member
    Join Date
    Oct 2009
    Location
    Missouri
    Posts
    770

    Re: [HELP!] Stupid Run Time error 91....

    Well, just load a picture from a file, and use it with bitblt.
    Rate my post if i helped you!


    Button Configuration Control For VB6 GetAsyncKeyState
    I'm the 7th best high school programmer in the nation!(according to SkillsUSA Nationals)(Used C#.Net)

  6. #6
    PowerPoster
    Join Date
    Jul 2006
    Location
    Maldon, Essex. UK
    Posts
    6,334

    Re: [HELP!] Stupid Run Time error 91....

    Is there any reason why you can't draw picRedBrick on the Form at design time ? That would be a common way of creating a PictureBox which you can subsequently 'play' with in your code.

  7. #7

    Thread Starter
    Fanatic Member
    Join Date
    Oct 2009
    Location
    Missouri
    Posts
    770

    Re: [HELP!] Stupid Run Time error 91....

    Yeah... But i just thought it would be more profesional to use files from the computer and such. and wouldn't doing that take up more space than just the lone file?
    Rate my post if i helped you!


    Button Configuration Control For VB6 GetAsyncKeyState
    I'm the 7th best high school programmer in the nation!(according to SkillsUSA Nationals)(Used C#.Net)

  8. #8
    PowerPoster
    Join Date
    Jul 2006
    Location
    Maldon, Essex. UK
    Posts
    6,334

    Re: [HELP!] Stupid Run Time error 91....

    Not too sure what you mean, in order to display a picture you need a container, like a PictureBox. The easiest way to achieve that is to draw it at design time. Once that's established you can load a Picture into it using LoadPicture and then BitBlt and 'play' with it to your hearts content.

  9. #9

    Thread Starter
    Fanatic Member
    Join Date
    Oct 2009
    Location
    Missouri
    Posts
    770

    Re: [HELP!] Stupid Run Time error 91....

    Yeah. I have done bitblt that way before. But with the form1.frx(stores images), would that be bigger than the actual images themselfs?
    Rate my post if i helped you!


    Button Configuration Control For VB6 GetAsyncKeyState
    I'm the 7th best high school programmer in the nation!(according to SkillsUSA Nationals)(Used C#.Net)

  10. #10
    Super Moderator si_the_geek's Avatar
    Join Date
    Jul 2002
    Location
    Bristol, UK
    Posts
    41,974

    Re: [HELP!] Stupid Run Time error 91....

    It might be... try it and see.

    Note however that it is irrelevant to whether or not the picturebox exists at design time - there is nothing forcing you to add a picture to a picturebox.

  11. #11

    Thread Starter
    Fanatic Member
    Join Date
    Oct 2009
    Location
    Missouri
    Posts
    770

    Re: [RESOLVED] [HELP!] Stupid Run Time error 91....

    Hmm. Okay. Thanks!
    Rate my post if i helped you!


    Button Configuration Control For VB6 GetAsyncKeyState
    I'm the 7th best high school programmer in the nation!(according to SkillsUSA Nationals)(Used C#.Net)

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