程序逻辑上是对的,没什么大问题,
但是中间为什么加了这么多End呢?End不就是让程序结束吗?你按第二个按钮的时候程序不会退出吗?
而且你的窗体一定要够长够宽哦,form1的height至少要大于9020左右,你这个矩形是往右上角移动的,如果窗体太小,Form1Height - c(1, 2)就成负数了,根本画不出来。
实现任意两图像控件中的图像被点击后交换的代码:
Private Sub Picture1_Click()'
MePicture = Picture1Picture'
Picture1Picture = Picture2Picture'
Picture2Picture = MePicture'
MePicture = Nothing'
End Sub
扩展资料:
“Visual” 指的是开发图形用户界面 (GUI) 的方法——不需编写大量代码去描述界面元素的外观和位置,而只要把预先建立的对象add到屏幕上的一点即可。
“Basic”指的是 BASIC (Beginners All-Purpose Symbolic Instruction Code) 语言,是一种在计算技术发展历史上应用得最为广泛的语言。
Visual Basic源自于BASIC编程语言。VB拥有图形用户界面(GUI)和快速应用程序开发(RAD)系统,可以轻易的使用DAO、RDO、ADO连接数据库,或者轻松的创建Active X控件,用于高效生成类型安全和面向对象的应用程序。程序员可以轻松的使用VB提供的组件快速建立一个应用程序。
参考资料来源:百度百科-Visual Basic
'把图像读取到字节数组中进行处理:
Private Declare Function GetBitmapBits Lib "gdi32" (ByVal hBitmap As Long, ByVal dwCount As Long, lpBits As Any) As Long
Private Declare Function SetBitmapBits Lib "gdi32" (ByVal hBitmap As Long, ByVal dwCount As Long, lpBits As Any) As Long
Private Declare Function GetObject Lib "gdi32" Alias "GetObjectA" (ByVal hObject As Long, ByVal nCount As Long, lpObject As Any) As Long
Private Type Bitmap
bmType As Long
bmWidth As Long
bmHeight As Long
bmWidthBytes As Long
bmPlanes As Integer
bmBitsPixel As Integer
bmBits As Long
End Type
Sub ReverseImage(img As StdPicture, Optional UpDownOrLeftRight As Boolean = False)
With img
Dim BmpInfo As Bitmap
GetObject Handle, Len(BmpInfo), BmpInfo
Dim BytesPixel As Integer
BytesPixel = BmpInfobmBitsPixel / 8
Dim Bits() As Byte
ReDim Bits(BmpInfobmWidthBytes - 1, BmpInfobmHeight - 1)
GetBitmapBits Handle, BmpInfobmWidthBytes BmpInfobmHeight, Bits(0, 0)
Dim rBits() As Byte
ReDim rBits(BmpInfobmWidthBytes - 1, BmpInfobmHeight - 1)
Dim Y As Integer, X As Integer
Dim p As Integer
If UpDownOrLeftRight Then
Dim rR As Integer, sR As Integer
For Y = BmpInfobmHeight - 1 To 0 Step -1
rR = BmpInfobmHeight - 1 - Y
For X = 0 To BmpInfobmWidthBytes - 1
rBits(X, rR) = Bits(X, Y)
Next X
Next Y
Else
Dim rIndex As Integer
Dim sIndex As Integer
For Y = 0 To BmpInfobmHeight - 1
For X = BmpInfobmWidth - 1 To 0 Step -1
sIndex = X BytesPixel
rIndex = (BmpInfobmWidth - 1 - X) BytesPixel
For p = sIndex To sIndex + 2
rBits(rIndex, Y) = Bits(p, Y)
rIndex = rIndex + 1
Next
Next X
Next Y
End If
Call SetBitmapBits(Handle, BmpInfobmWidthBytes BmpInfobmHeight, rBits(0, 0))
End With
End Sub
'在窗体上添加一个标签框,一个计时器
Private Sub Form_Load()
Label1Width=300
Label1Height=300
Label1Caption=""
Label1BackColor=vbRed
Timer1Interval=20
Timer1Enabled=True
End Sub
Private Sub Timer1_Timer()
Const PI=31415926
Static Theta as Long
Dim R as Double,X0 as Double,Y0 as Double
X0=Form1ScaleWidth/2
Y0=Form1ScaleHeight/2
R= IIf(X0>Y0,Y0,X0) /2
Theta=theta+5
Label1Move X0+RCos(thetaPi/180)-Label1Width/2,Y0+RSin(ThetaPi/180)-Label1Height/2
End Sub
以上就是关于关于vb的一个问题全部的内容,包括:关于vb的一个问题、在vb中如何实现任意两图像控件中的图像被点击后交换、vb 图片翻转(水平和竖直)函数代码等相关内容解答,如果想了解更多相关内容,可以关注我们,你们的支持是我们更新的动力!
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)