-
code:
Option Explicit
Private Sub Form_Click()
' Declare variables.
Dim CX, CY, Limit, Radius As Integer, Msg As String
ScaleMode = vbPixels ' Set scale to pixels.
AutoRedraw = True ' Turn on AutoRedraw.
Width = Height ' Change width to match height.
CX = ScaleWidth / 2 ' Set X position.
CY = ScaleHeight / 2 ' Set Y position.
Limit = CX ' Limit size of circles.
For Radius = 0 To Limit ' Set radius.
Picture1.Circle (CX, CY), Radius, _
RGB(Rnd * 255, Rnd * 255, Rnd * 255)
DoEvents ' Yield for other processing.
Next Radius
Msg = "Choose OK to save the graphics from this form "
Msg = Msg & "to a bitmap file."
MsgBox Msg
SavePicture Picture1.Image, _
"TEST.BMP" ' Save picture to file.
End Sub
This works for good if the circles are assigned to the picture prop of the form, however when assigned to the image of the picture test.bmp returns empty. Why and how does that happen?
-
Try this:
Code:
Option Explicit
Private Sub Form_Click()
' Declare variables.
Dim CX, CY, Limit, Radius As Integer, Msg As String
ScaleMode = vbPixels ' Set scale to pixels.
AutoRedraw = True ' Turn on AutoRedraw.
Width = Height ' Change width to match height.
CX = ScaleWidth / 2 ' Set X position.
CY = ScaleHeight / 2 ' Set Y position.
Limit = CX ' Limit size of circles.
For Radius = 0 To Limit ' Set radius.
Picture1.Circle (CX, CY), Radius, _
RGB(Rnd * 255, Rnd * 255, Rnd * 255)
DoEvents ' Yield for other processing.
Next Radius
Msg = "Choose OK to save the graphics from this form "
Msg = Msg & "to a bitmap file."
MsgBox Msg
[b]SavePicture Picture1.Picture, _
"TEST.BMP" ' Save picture to file.[b]
End Sub
-
I don't know what's the problem with the first code.
I just tried it and it works great!
-
Sorry, errored!
I tried it beforehand. But I gave it a chance 2nd time, it's all the same : "Invalid property error! (380)" :(
Any other suggestions?