VB程序学习代码记录20160804

2019-04-15 13:48发布

翻转图片 Dim sp As Boolean Dim cz As Boolean Private Sub Command1_Click(Index As Integer) Dim pic As StdPicture Dim w, h As Integer w = Picture1.Width h = Picture1.Height Set pic = Picture1.Picture Picture1.Cls Select Case Index Case 0 sp = Not sp Case 1 cz = Not cz Case 2 End end select If sp And cz Then Picture1.PaintPicture pic, w, h, w * -1, h * -1 ElseIf sp And Not cz Then Picture1.PaintPicture pic, w, 0, w * -1, h ElseIf Not sp And cz Then Picture1.PaintPicture pic, 0, h, w, h * -1 Else Picture1.PaintPicture pic, 0, 0 End If End Sub Private Sub commond2_Click() CommonDialog1.FileName = "" CommonDialog1.Filter = "图像文件|*.jpg;*.gif;*.png;*.PNG;*.bmp" CommonDialog1.Flags = cdlOFNAllowMultiselect '这个选项可使多选,所以要对文件串进行处理。 CommonDialog1.ShowOpen Dim a a = Split(CommonDialog1.FileName, " ") If UBound(a) = 0 Then Picture1.Picture = LoadPicture(a(0)) If UBound(a) > 0 Then Picture1.Picture = LoadPicture(a(0) & a(1)) If UBound(a) > 1 Then Picture2.Picture = LoadPicture(a(0) & a(2)) If Err.Number = 481 Then MsgBox "请选择图片文件" End If End Sub