2016-10-12 44 views
0
Dim nPicture As Integer 
For n = 1 To 4 
    If p_strInstrument(n, 0) = "A" Then 
     nPicture = (n * 4) + 1 
    Else 
     nPicture = (n * 4) + 4 
    End If 
    'How Can i edit the line below? 
    frm_Experiment.picInstrument(n).Picture = frm_Experiment.ImageListInstrument.ListImages(nPicture).Picture 
Next n 

p_blnInstReady = True 
'Unload Me 
frm_SearchInstrument.WindowState = vbMinimized 
frm_SearchInstrument.Visible = False 
+1

將VB6標籤標記爲C#和Objective-C是一個壞主意......正如轉儲無格式代碼的負載沒有任何細節。你已經在這裏傾倒了近600行代碼......你真的希望別人弄清楚哪個是相關的代碼嗎?請閱讀https://codeblog.jonskeet.uk/2010/08/29/writing-the-perfect-question/ –

+0

嗨喬恩,對不起,我是新的,我不知道太多....下面的代碼行需要編輯 – Prince

+0

閱讀博客文章 - 爲什麼你添加了Javascript,ASP.NET和.NET標籤?說明中沒有*表示它們是相關的。 –

回答

2

你得到的錯誤,因爲你的控制稱爲picInstrument,沒有一個是有一個Index屬性的數組評估爲3.檢查陣列中每個控件的Index屬性,並確保它們從1到4,就像您的For循環一樣。

儘管如此,你最好從0開始,然後在For循環中從0到3。

+0

感謝BobRodes ....我實際上從0到2修復它,因爲它的最後兩個樂器我不想看到..... – Prince

+0

這很有效。所以,也許你可以接受這個答案,以便其他人在遇到同樣的問題時能夠更快地看到解決方案。附:盡你所能在未來的帖子中遵循Jon Skeet的建議。 :) – BobRodes