SavePicture Statement

See Also2KE8W11              Example3L8KE4C>Low

Saves a picture from a form, picture box, or image control into a file.

Syntax

SavePicture picture, stringexpression

Remarks

The SavePicture statement has these parts:

Part                           Description

 

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 timeCFSL0V or at run timeCYRM35, it is saved using the same format as the original file. Pictures from the Image property are always saved as bitmap (.BMP) files.


See Also

Image Property6AEZWAR

LoadPicture Function1F02FRP

Picture Property4GBE5Q


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.

   Next Radius

   Msg = "Choose OK to save the graphics from this form "

   Msg = Msg & "to a bitmap file."

   MsgBox Msg

   SavePicture Image, "TEST.BMP"         ' Save picture to file.

End Sub