請各位VB高手幫幫忙,
在Project 中,我共有兩個forms和一個module,在其中一個form中放置了ImageCombo Control and ImageList Control ,當我在ImageCombo中選了圖片后,如何在另一個form中將圖片及其file name and file size顯示出來?我將各Image的 file name 寫在ImageList control 中的Tag,不知這樣是否正確?
以下code是否有甚麼問題:
1)module code
Public vntSelImage As Variant
Public strFileName As String
2)form1 code
Private Sub Form_Load()
Dim i As Integer
' Attach the ImageCombo to the ImageList that
  ' holds its pictures.
  Set imgcboImage.ImageList = ImageList1

' Create some items.
  For i = 1 To ImageList1.ListImages.Count
    imgcboImage.ComboItems.Add , , ImageList1.ListImages(i).Key, i
  Next i

' Select the first item.
  Set imgcboImage.SelectedItem = imgcboImage.ComboItems(1)
  
End Sub
Private Sub imgcboImage_Click()
strFileName = imgcboImage.SelectedItem.Tag
  vntSellmage = imgcboImage.SelectedItem.Image
End Sub
3)form2
Private Sub Form_Load()
lblImageFile.Caption = strFileName
  imgSelImage = vntSelImage
End Sub
萬分感謝!
php
arrow
arrow
    全站熱搜

    vbqa 發表在 痞客邦 留言(1) 人氣()