使用loadPicture和SavePicture函数呀本例使用 LoadPicture 函数将图片加载到窗体的 PictureBox 控件并从控件上清除掉该图片。要试用此例,将 PictureBox 控件添加入 Form 对象,然后将以下代码粘贴到 Form 的声明部分,然后运行此例,单击 Form 。Private Sub Form_Click () Dim Msg as String ' 声明变量。 On Error Resume Next ' 设置错误句柄。 Height = 3990 Width = 4890 ' 设置高度和宽度。 Picture1.Picture = LoadPicture("PAPER.CUR", vbLPCustom, vbLPColor, 32, 32) ' 加载光标。 If Err Then Msg = "Couldn't find the .cur file." MsgBox Msg ' 显示错误消息。 Exit Sub ' 如果发生错误则退出。 End If Msg = "Choose OK to clear the bitmap from the form." MsgBox Msg Picture1.Picture = LoadPicture() '清除 picturebox。End SubSavePicture 语句示例 本例使用 SavePicture 语句保存画在 Form 对象的 Picture 属性中的图形。要试用此例,可将以下代码粘贴到 Form 对象的声明部分,然后运行此例,单击 Form 对象。Private Sub Form_Click () ' 声明变量。 Dim CX, CY, Limit, Radius as Integer, Msg as String ScaleMode = vbPixels ' 设置比例模型为像素。 AutoRedraw = True ' 打开 AutoRedraw。 Width = Height ' 改变宽度以便和高度匹配。 CX = ScaleWidth / 2 ' 设置 X 位置。 CY = ScaleHeight / 2 ' 设置 Y 位置。 Limit = CX ' 圆的尺寸限制。 For Radius = 0 To Limit ' 设置半径。 Circle (CX, CY), Radius, RGB(Rnd * 255, Rnd * 255, Rnd * 255) DoEvents ' 转移到其它操作。 Next Radius Msg = "Choose OK to save the graphics from this form " Msg = Msg & "to a bitmap file." MsgBox Msg SavePicture Image, "TEST.BMP" ' 将图片保存到文件。 End Sub欢迎访问小站www.lihuasoft.net
Dim Msg as String ' 声明变量。
On Error Resume Next ' 设置错误句柄。
Height = 3990
Width = 4890 ' 设置高度和宽度。
Picture1.Picture = LoadPicture("PAPER.CUR", vbLPCustom, vbLPColor, 32, 32) ' 加载光标。
If Err Then
Msg = "Couldn't find the .cur file."
MsgBox Msg ' 显示错误消息。
Exit Sub ' 如果发生错误则退出。
End If
Msg = "Choose OK to clear the bitmap from the form."
MsgBox Msg
Picture1.Picture = LoadPicture() '清除 picturebox。End SubSavePicture 语句示例
本例使用 SavePicture 语句保存画在 Form 对象的 Picture 属性中的图形。要试用此例,可将以下代码粘贴到 Form 对象的声明部分,然后运行此例,单击 Form 对象。Private Sub Form_Click ()
' 声明变量。
Dim CX, CY, Limit, Radius as Integer, Msg as String
ScaleMode = vbPixels ' 设置比例模型为像素。
AutoRedraw = True ' 打开 AutoRedraw。
Width = Height ' 改变宽度以便和高度匹配。
CX = ScaleWidth / 2 ' 设置 X 位置。
CY = ScaleHeight / 2 ' 设置 Y 位置。
Limit = CX ' 圆的尺寸限制。
For Radius = 0 To Limit ' 设置半径。
Circle (CX, CY), Radius, RGB(Rnd * 255, Rnd * 255, Rnd * 255)
DoEvents ' 转移到其它操作。
Next Radius
Msg = "Choose OK to save the graphics from this form "
Msg = Msg & "to a bitmap file."
MsgBox Msg
SavePicture Image, "TEST.BMP" ' 将图片保存到文件。
End Sub欢迎访问小站www.lihuasoft.net