導航:首頁 > 文件教程 > vb載入文件夾內所有圖片listbox

vb載入文件夾內所有圖片listbox

發布時間:2023-09-16 08:02:12

1. VB遍歷文件夾中的圖片

添加文件列表控制項,filelist
Dim Shunxu As Integer, zongshu As Integer, strfilename As String
Private Sub Form_Load()
File1.Path = "d:\" ' "d:\123\圖片文件夾" '文件夾路徑
File1.Pattern = "*.gif" '文件格式
Timer1.Interval = 1000
Timer1.Enabled = True
zongshu = File1.ListCount '總數
Shunxu = 0
End Sub

Private Sub Timer1_Timer()
If zongshu > 0 Then
strfilename = File1.List(Shunxu) '圖片文件名
Image1.Picture = LoadPicture(File1.Path + "\" + strfilename) '圖片文件路徑
Shunxu = Shunxu + 1
If Shunxu = zongshu - 1 Then
Shunxu = 0
End If
End If
End Sub

2. VB2008讀取文件夾中所有文件JPG

用Microsoft.VisualBasic.FileIO.Filesystem.GetFiles方法。在文件名參數寫"*.jpg"就行了。返回ReadOnlyCollection。記住:READONLYCOLLECTION的Item屬性最大值為Count-1不是count
然後用for循環將readonlycollection的項添加到ListBox控制項。把郵箱給我,過兩天把代碼發給你
代碼

On Error Resume Next'最好使用VB.NET 的Try catch語句塊
dim Loopint1 as integer,tmpstr1,tmpstr3 as string
Dim flist As System.Collections.ObjectModel.ReadOnlyCollection(Of String)
fList=Microsoft.VisualBasic.FileIO.FileSystem.GetFiles(gfPath, FileIO.SearchOption.SearchTopLevelOnly, "*.jpg")
x = flist.Count
For LoopInt1 = 0 To x - 1 '循環控制
tmpstr3 = "" '清空屬性字元串
tmpstr1 = flist.Item(LoopInt1)
IntInStr = InStrRev(tmpstr1, "\")
tmpstr2 = Microsoft.VisualBasic.Strings.Right(tmpstr1, Len(tmpstr1) - IntInStr)'只得到文件名,如果要完整路徑就要循環里第二行即可
Listbox1.Items.Add(tmpstr2)'添加內容
Next
'其實完全可以製作一個VB6的文件列表框,加上Listview,資源管理器也是可以做的,只不過圖標控制比較麻煩而已
'照相時間要獲得EXIF信息,這個我不知道,你上網找找看

閱讀全文

與vb載入文件夾內所有圖片listbox相關的資料

熱點內容
工廠里都招什麼編程人員 瀏覽:932
jspsql登錄 瀏覽:981
網路用語粉絲閱讀什麼意思 瀏覽:333
紅頭文件怎麼列印 瀏覽:94
熱血江湖130刺客升級 瀏覽:106
jsp頁面放大鏡技術介紹 瀏覽:101
網路編程udp 瀏覽:148
加密壓縮文件如何打開 瀏覽:56
微軟編程軟體有哪些 瀏覽:736
linux目錄中創建文件夾許可權設置密碼 瀏覽:759
word文檔正式文件模版 瀏覽:247
linux文件系統的類型是 瀏覽:111
蘋果的無線傳輸文件找不到了 瀏覽:102
密件文件名能出現在通知嗎 瀏覽:832
編寫一個web應用程序 瀏覽:350
哪些場所網路好 瀏覽:171
華為手機怎麼找到以前安裝過的app 瀏覽:100
49塊一單約人陪的app是什麼 瀏覽:570
ug文件格式圖片 瀏覽:24
興趣班編程課是學什麼 瀏覽:879

友情鏈接