[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?
Re: [HELP!] Stupid Run Time error 91....
Quote:
Originally Posted by
Gamemaster1494
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.
Re: [HELP!] Stupid Run Time error 91....
Okay. I did that and it still highlights it and says the same thing.
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 ?
Re: [HELP!] Stupid Run Time error 91....
Well, just load a picture from a file, and use it with bitblt.
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.
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?
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.
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?
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.
Re: [RESOLVED] [HELP!] Stupid Run Time error 91....