在vb中如何实现任意两图像控件中的图像被点击后交换

在vb中要放置了3个图像控件,如何实现任意点击两个图像控件就能将相应的图像交换,谢谢... 在vb中要放置了3个图像控件,如何实现任意点击两个图像控件就能将相应的图像交换,谢谢 展开
 我来答
ser0326
2019-11-19 · TA获得超过1.4万个赞
知道答主
回答量:30
采纳率:100%
帮助的人:7280
展开全部

实现任意两图像控件中的图像被点击后交换的代码:

Private Sub Picture1_Click()'

Me.Picture = Picture1.Picture'

Picture1.Picture = Picture2.Picture'

Picture2.Picture = Me.Picture'

Me.Picture = 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

铭刻39657ca6037
推荐于2016-11-20 · TA获得超过426个赞
知道答主
回答量:280
采纳率:96%
帮助的人:70.6万
展开全部
比较笨的方法,我想不出好办法来。放4个Picture控件,其中1个为Tmp并设置为不可见。代码如下 Option Explicit Private Sub Pct1_Click() With Pct1 If Pct2.Tag = "1" Then Tmp.Picture = .Picture .Picture = Pct2.Picture Pct2.Picture = Tmp.Picture Pct2.Tag = "0" ElseIf Pct3.Tag = "1" Then Tmp.Picture = .Picture .Picture = Pct3.Picture Pct3.Picture = Tmp.Picture Pct3.Tag = "0" Else .Tag = "1" End If End With End Sub Private Sub Pct2_Click() With Pct2 If Pct1.Tag = "1" Then Tmp.Picture = .Picture .Picture = Pct1.Picture Pct1.Picture = Tmp.Picture Pct1.Tag = "0" ElseIf Pct3.Tag = "1" Then Tmp.Picture = .Picture .Picture = Pct3.Picture Pct3.Picture = Tmp.Picture Pct3.Tag = "0" Else .Tag = "1" End If End With End Sub Private Sub Pct3_Click() With Pct3 If Pct1.Tag = "1" Then Tmp.Picture = .Picture .Picture = Pct1.Picture Pct1.Picture = Tmp.Picture Pct1.Tag = "0" ElseIf Pct2.Tag = "1" Then Tmp.Picture = .Picture .Picture = Pct2.Picture Pct2.Picture = Tmp.Picture Pct2.Tag = "0" Else .Tag = "1" End If End With End Sub
本回答被提问者采纳
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
道友系列12368
2014-06-28 · TA获得超过109个赞
知道答主
回答量:124
采纳率:0%
帮助的人:116万
展开全部
创建Image0、Image1、Image2、Image3,代码长了一点却很简单 Dim p1 As Boolean, p2 As Boolean, p3 As Boolean Private Sub Form_Load() Image0.Visible = False p1 = False: p2 = False: p3 = False End Sub Private Sub Image1_Click() p1 = True If p2 = True Then Image0.Picture = Image1.Picture Image1.Picture = Image2.Picture Image2.Picture = Image0.Picture p1 = False: p2 = False End If If p3 = True Then Image0.Picture = Image1.Picture Image1.Picture = Image3.Picture Image3.Picture = Image0.Picture p1 = False: p3 = False End If End Sub Private Sub Image2_Click() p2 = True If p1 = True Then Image0.Picture = Image2.Picture Image2.Picture = Image1.Picture Image1.Picture = Image0.Picture p2 = False: p1 = False End If If p3 = True Then Image0.Picture = Image2.Picture Image2.Picture = Image3.Picture Image3.Picture = Image0.Picture p2 = False: p3 = False End If End Sub Private Sub Image3_Click() p3 = True If p1 = True Then Image0.Picture = Image3.Picture Image3.Picture = Image1.Picture Image1.Picture = Image0.Picture p3 = False: p1 = False End If If p2 = True Then Image0.Picture = Image3.Picture Image3.Picture = Image2.Picture Image2.Picture = Image0.Picture p3 = False: p2 = False End If End Sub
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
鱼木混猪哟
高粉答主

推荐于2016-02-16 · 专注Office,尤其Excel和VBA
鱼木混猪哟
采纳数:6078 获赞数:33696

向TA提问 私信TA
展开全部
代码及注释如下:
Private Sub Picture1_Click()'图像1点击时,执行代码,同样,可以设置图像2点击时执行代码
Me.Picture = Picture1.Picture'用me作为中间过度,先将p1图像临时存于me中
Picture1.Picture = Picture2.Picture'让p1图像等于P2
Picture2.Picture = Me.Picture'让P2图像等于me,也就是原来P1的图像,从而实现教皇
Me.Picture = Nothing'清空me
End Sub
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
收起 1条折叠回答
收起 更多回答(2)
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式