大橙子网站建设,新征程启航
为企业提供网站建设、域名注册、服务器等服务
'先画个按钮,名字叫Command1
创新互联主打移动网站、网站设计制作、网站设计、网站改版、网络推广、网站维护、域名申请、等互联网信息服务,为各行业提供服务。在技术实力的保障下,我们为客户承诺稳定,放心的服务,根据网站的内容与功能再决定采用什么样的设计。最后,要实现符合网站需求的内容、功能与设计,我们还会规划稳定安全的技术方案做保障。
'下面这几行是按钮按下
Private
Sub
Command1_Click()
Command1.Picture
=
LoadPicture("鼠标按下变换那张图片的路径")
End
Sub
'下面几行是鼠标滑过
Private
Sub
Command1_MouseMove(Button
As
Integer,
Shift
As
Integer,
X
As
Single,
Y
As
Single)
Command1.Picture
=
LoadPicture("鼠标滑过图片变换那张图片的路径")
End
Sub
'下面几行是原来的图片和鼠标离开按钮时的图片
Private
Sub
Form_MouseMove(Button
As
Integer,
Shift
As
Integer,
X
As
Single,
Y
As
Single)
Command1.Picture
=
LoadPicture("原来按钮图片路径")
End
Sub
在按钮中添加代码:
Me.Picture = LoadPicture("C:\图片.bmp")
或者
Me.Picture = LoadPicture("C:\图片.jpg")
即可更换窗体的背景图片。图片可以是BMP或JPG格式。
vb.net 怎么来回切换图片?1、添加控件Picturebox1和控件Timer1,将Timer1的Interval属性改为1000(即1秒),Enabled属性改为True
2、假设你要循环切换4张图片,你可以添加如下代码即可实现:
Dim a As Integer = 0
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
If a = 4 Then
a = 0
Else
a = a + 1
End If
If a = 0 Then Me.PictureBox1.Image = Image.FromFile("1.jpg")
If a = 1 Then Me.PictureBox1.Image = Image.FromFile("2.jpg")
If a = 2 Then Me.PictureBox1.Image = Image.FromFile("3.jpg")
If a = 3 Then Me.PictureBox1.Image = Image.FromFile("4.jpg")
End Sub
用Button控件就可以了 修改BackgroundImage 属性 类似这样
Button1.BackgroundImage = Image.FromFile("C:\Users\hp\Desktop\EMOTICONS\EMOTICON SMILE.png")
如果要实现动态效果的话需要2个图片当Button1_MouseHover事件时也就是鼠标停留在button上的时候显示一个图片,当Button1_MouseLeave事件时,也就是鼠标离开button时显示原来的图片,这样就是动态的了.
'在窗体上添加一个按钮测试
Private
m_PlayFlag
As
Boolean
=
False
'是否正在播放
Private
Sub
Button1_Click(ByVal
sender
As
System.Object,
ByVal
e
As
System.EventArgs)
Handles
Button1.Click
If
m_PlayFlag
=
False
Then
Button1.Image
=
Image.FromFile("d:\play.jpg")
'更换为播放图标
m_PlayFlag
=
True
'改变标志
Else
Button1.Image
=
Image.FromFile("d:\pause.jpg")
'更换为暂停图标
m_PlayFlag
=
False
'改变标志
End
If
End
Sub
Private
Sub
Form1_Load(ByVal
sender
As
System.Object,
ByVal
e
As
System.EventArgs)
Handles
MyBase.Load
'窗体加载时使用暂停图标
Button1.Image
=
Image.FromFile("d:\pause.jpg")
End
Sub