[VB 2005] 用變數指定物件

看板Visual_Basic作者 (我是小狗丁丁的娘)時間18年前 (2007/06/17 16:40), 編輯推噓3(305)
留言8則, 2人參與, 最新討論串1/1
我有picturebox1~picturebox9 想設一個參數n 讓n=1時 改變picturebox1.Image=OOXX n=2時 改變picturebox2.Image=XXOO 看到板上.NET是用類似"Me.FindControl("tx" & i).Text = i"的寫法 在2005上 我寫Me.Control("picturebox" & n).Image 是不行的(沒有Image可以選) 想請問一下 在2005上 要怎麼寫可以達到像是 picturebox(n).Image=OOOXXX 的用法 請厲害的高手們解答 謝謝m(_ _)m -- 紐西蘭+澳洲35天之旅~╭(′▽`)╯╭(′▽`)╯╭(′▽`)╯ http://www.wretch.cc/blog/wen1015 天天都有日記 -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 218.166.216.194

06/17 17:56, , 1F
因為 Control("xxx") 的型別是 Control,它沒有這個屬性~
06/17 17:56, 1F

06/17 17:56, , 2F
可是其實這個Control是PictureBox,所以你要把他轉成Pictur
06/17 17:56, 2F

06/17 17:57, , 3F
eBox先~作法是用 CType(Control("xx"),PictureBox)
06/17 17:57, 3F

06/17 17:58, , 4F
然後 CType(好長一串).Image就是你要的東西了~~
06/17 17:58, 4F
※ 編輯: wen1015 來自: 218.166.218.177 (06/17 18:06)

06/17 18:09, , 5F
是CType(Control("pixturebox"), PictureBox).Image嗎
06/17 18:09, 5F

06/17 18:11, , 6F
試了還是不行耶
06/17 18:11, 6F

06/18 15:11, , 7F
喔喔 解決了 picturebox不但要大小寫 而且我還拼錯= =
06/18 15:11, 7F

06/18 15:12, , 8F
感謝
06/18 15:12, 8F
文章代碼(AID): #16TFDZeD (Visual_Basic)