Private?Sub?Button1_Click(sender?As?Object,?e?As?EventArgs)?Handles?Button1.Click
成都創(chuàng)新互聯(lián)公司是創(chuàng)新、創(chuàng)意、研發(fā)型一體的綜合型網(wǎng)站建設(shè)公司,自成立以來(lái)公司不斷探索創(chuàng)新,始終堅(jiān)持為客戶(hù)提供滿(mǎn)意周到的服務(wù),在本地打下了良好的口碑,在過(guò)去的十年時(shí)間我們累計(jì)服務(wù)了上千家以及全國(guó)政企客戶(hù),如成都混凝土攪拌機(jī)等企業(yè)單位,完善的項(xiàng)目管理流程,嚴(yán)格把控項(xiàng)目進(jìn)度與質(zhì)量監(jiān)控加上過(guò)硬的技術(shù)實(shí)力獲得客戶(hù)的一致贊揚(yáng)。
'建立新的系統(tǒng)進(jìn)程????
Dim?process?As?New?System.Diagnostics.Process()
If?RadioButton1.Checked?Then
'設(shè)置文件名,此處為圖片的真實(shí)路徑+文件名????
process.StartInfo.FileName?=?"c:\a.bmp"
'設(shè)置進(jìn)程運(yùn)行參數(shù)????
process.StartInfo.Arguments?=?"rundll32.exe?shimgvw.dll"
Else
process.StartInfo.FileName?=?"mspaint.exe"
process.StartInfo.Arguments?=?"c:\a.bmp"
End?If
'此項(xiàng)為是否使用Shell執(zhí)行程序,因系統(tǒng)默認(rèn)為true,此項(xiàng)也可不設(shè),但若設(shè)置必須為true????
'process.StartInfo.UseShellExecute?=?True
'此處可以更改進(jìn)程所打開(kāi)窗體的顯示樣式,可以不設(shè)????
'process.StartInfo.WindowStyle?=?System.Diagnostics.ProcessWindowStyle.Hidden
process.Start()
process.Close()
End?Sub
Public Class Form1
Private TPS As Integer
Private TPPath() As String '定義不確定元素個(gè)數(shù)組,及動(dòng)態(tài)數(shù)組
Private Sub LoadPhoto()
'將圖片路徑及圖片名加載到數(shù)組
Dim JS As Integer '計(jì)數(shù)用
For Each foundFile As String In My.Computer.FileSystem.GetFiles(CurDir() "\職員圖片")
TPS = TPS + 1 '將圖片數(shù)存入變量中
Next
ReDim TPPath(TPS - 1) '確定數(shù)組大小
For Each FoundFile As String In My.Computer.FileSystem.GetFiles(CurDir() "\職員圖片")
'將圖片路徑存入數(shù)組
TPPath(JS) = FoundFile
JS = JS + 1
Next
End Sub
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
LoadPhoto()
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Label1.Text = TPPath.Length '獲取數(shù)組大小
Label1.Text = TPPath(1) '獲取數(shù)組中第2個(gè)元素的值
End Sub
IO.Directory.GetFiles
獲取指定目錄中的所有文件,比對(duì)文件名就行了。如果包括多層子目錄,需要遞歸
在自定義工具箱中選擇dirlistbox,drivelistbox,filelistbox,添加這3個(gè)控件,然后在窗體上添加這些控件和一個(gè)picturebox控件,代碼如下:
Public Class Form1
Private Sub DirListBox1_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles DirListBox1.SelectedIndexChanged
FileListBox1.Path = DirListBox1.Path
End Sub
Private Sub DriveListBox1_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles DriveListBox1.SelectedIndexChanged
DirListBox1.Path = DriveListBox1.Drive
End Sub
Private Sub FileListBox1_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles FileListBox1.SelectedIndexChanged
PictureBox1.Image = Image.FromFile(FileListBox1.Path + "\" + FileListBox1.SelectedItem.ToString())
End Sub
End Class
你可以自己在修改下,這只是個(gè)模型,呵呵!
轉(zhuǎn)換成位圖肯定是可以瀏覽的,WMF文件沒(méi)試過(guò)。
你可以將圖片以二進(jìn)制形式存儲(chǔ)在數(shù)據(jù)庫(kù)中,如果是SQL Server,對(duì)應(yīng)字段的類(lèi)型應(yīng)該是image。
窗體上放一個(gè)PictureBox,兩個(gè)CommandButton,一個(gè)FileListBox
Private Sub Command1_Click()
If File1.ListIndex = 0 Then
ShowPic File1.ListCount - 1
Else
ShowPic File1.ListIndex - 1
End If
End Sub
Private Sub Command2_Click()
If File1.ListIndex = File1.ListCount - 1 Then
ShowPic 0
Else
ShowPic File1.ListIndex + 1
End If
End Sub
Private Sub Form_Load()
File1.Visible = False
File1.Pattern = "*.jpg;*.gif" '可以瀏覽的文件類(lèi)型,使用分號(hào)隔開(kāi)
File1.Path = App.Path '改成你需要瀏覽的目錄,比如"C:\Pic"
If File1.ListCount 1 Then '目錄中圖片在兩張以上可以瀏覽
ShowPic 0
Exit Sub
ElseIf File1.ListCount = 1 Then '目錄中只有一張圖片時(shí)只顯示這一張
ShowPic 0
End If
Command1.Enabled = False
Command2.Enabled = False
End Sub
Private Sub ShowPic(Index As Long)
File1.ListIndex = Index
Picture1.Picture = LoadPicture(File1.Path "\" File1.List(Index))
End Sub
如果對(duì)您有幫助,請(qǐng)記得采納為滿(mǎn)意答案,謝謝!祝您生活愉快!
vaela