See Also Example
Saves a picture from a form, picture box, or image control into a file.
SavePicture picture, stringexpression
The SavePicture statement has these parts:
picture Picture or Image property from which the picture file is to be created.
stringexpression File name of the picture file to save.
If a picture was loaded from file to the Picture property, either at design time or at run time , it is saved using the same format as the original file. Pictures from the Image property are always saved as bitmap (.BMP) files.
SavePicture Statement Example
The example uses the SavePicture statement to save a picture drawn on a form. To try this example, paste the code into the Declarations section of a form. Then press F5 and click the form.
Sub Form_Click ()
Dim CX, CY, Limit, Msg, Radius ' Declare variables.
ScaleMode = 3 ' Set scale to pixels.
AutoRedraw = -1 ' 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.
Circle (CX, CY), Radius, RGB(Rnd * 255, Rnd * 255, Rnd * 255)
DoEvents ' Yield for other processing.
Msg = "Choose OK to save the graphics from this form "
Msg = Msg & "to a bitmap file."
SavePicture Image, "TEST.BMP" ' Save picture to file.