怎样用VB做一个图片浏览器??
发布网友
发布时间:2023-01-18 06:53
我来回答
共2个回答
热心网友
时间:2023-11-22 13:08
Public Class Form1
Dim i As Integer
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
i = i - 1
If (i < 0) Then
i = 4
End If
'pic.Image = imgl.Images(i)
pic.Image = Image.FromFile(imgNames(i).FullName)
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
i = i + 1
If (i >= 4) Then
i = 0
End If
'pic.Image = imgl.Images(i)
pic.Image = Image.FromFile(imgNames(i).FullName)
End Sub
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
If Button3.Text Is "播放" Then
Timer1.Start()
Button3.Text = "暂停"
Else
Timer1.Stop()
Button3.Text = "播放"
End If
End Sub
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
i = i + 1
If (i >= 4) Then
i = 0
End If
'pic.Image = imgl.Images(i)
pic.Image = Image.FromFile(imgNames(i).FullName)
End Sub
Dim imgNames As IO.FileInfo()
Private Sub test2_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim _Url As String
_Url = Application.StartupPath & "\Imager" '获取程序文件信息所在的文件夹
Dim _ImgUrl As New System.IO.DirectoryInfo(_Url) '新建文件夹对象
imgNames = _ImgUrl.GetFiles("*.jpg") '从文件信息中获取文件对象的类型
End Sub
Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
FolderBrowserDialog1.ShowDialog()
Dim _Url As String
_Url = FolderBrowserDialog1.SelectedPath
Dim _ImgUrl As New System.IO.DirectoryInfo(_Url) '新建文件夹对象
imgNames = _ImgUrl.GetFiles("*.jpg") '从文件信息中获取文件对象的类型
End Sub
Dim form As New Form2
Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles form2Click.Click
Form.Show() '*************显示窗体
End Sub
Private Sub Button6_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button6.Click
Me.Close()
End Sub
Private Sub Button7_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button7.Click
form.Close()
End Sub
Private Sub Button8_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button8.Click
Dim clockF As New clock
clockF.ShowDialog()
End Sub
End Class
显示张数的用text显示出来就可以了
其实我也是初学者这些代码有些小BUG请包涵我会修改的
大家可以加个QQ交流交流
热心网友
时间:2023-11-22 13:09
1、用Picture显示图片
2、用Timer做自动轮换图片功能
3、还有重要的就是取得图片文件列表放进结构数组就可以了。
热心网友
时间:2023-11-22 13:08
Public Class Form1
Dim i As Integer
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
i = i - 1
If (i < 0) Then
i = 4
End If
'pic.Image = imgl.Images(i)
pic.Image = Image.FromFile(imgNames(i).FullName)
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
i = i + 1
If (i >= 4) Then
i = 0
End If
'pic.Image = imgl.Images(i)
pic.Image = Image.FromFile(imgNames(i).FullName)
End Sub
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
If Button3.Text Is "播放" Then
Timer1.Start()
Button3.Text = "暂停"
Else
Timer1.Stop()
Button3.Text = "播放"
End If
End Sub
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
i = i + 1
If (i >= 4) Then
i = 0
End If
'pic.Image = imgl.Images(i)
pic.Image = Image.FromFile(imgNames(i).FullName)
End Sub
Dim imgNames As IO.FileInfo()
Private Sub test2_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim _Url As String
_Url = Application.StartupPath & "\Imager" '获取程序文件信息所在的文件夹
Dim _ImgUrl As New System.IO.DirectoryInfo(_Url) '新建文件夹对象
imgNames = _ImgUrl.GetFiles("*.jpg") '从文件信息中获取文件对象的类型
End Sub
Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
FolderBrowserDialog1.ShowDialog()
Dim _Url As String
_Url = FolderBrowserDialog1.SelectedPath
Dim _ImgUrl As New System.IO.DirectoryInfo(_Url) '新建文件夹对象
imgNames = _ImgUrl.GetFiles("*.jpg") '从文件信息中获取文件对象的类型
End Sub
Dim form As New Form2
Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles form2Click.Click
Form.Show() '*************显示窗体
End Sub
Private Sub Button6_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button6.Click
Me.Close()
End Sub
Private Sub Button7_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button7.Click
form.Close()
End Sub
Private Sub Button8_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button8.Click
Dim clockF As New clock
clockF.ShowDialog()
End Sub
End Class
显示张数的用text显示出来就可以了
其实我也是初学者这些代码有些小BUG请包涵我会修改的
大家可以加个QQ交流交流
热心网友
时间:2023-11-22 13:09
1、用Picture显示图片
2、用Timer做自动轮换图片功能
3、还有重要的就是取得图片文件列表放进结构数组就可以了。