例如,我有一個程序,有10個按鈕,當我按下一個隨機的名字時,它的名字保存爲一個字符串,我想爲該按鈕的名稱添加1,例如,如果我按下按鈕1生病更改字符串說button2,但現在我不能使用該字符串,因爲它不能將字符串轉換爲system.windows.forms.buttons,我已經嘗試了Me.Controls bu它沒有爲我工作。將字符串轉換爲
例子:
dim stringy as string
dim integr as integer
dim buton as button
sub procedureee
stringy = stringy.remove(0,6)
integr = val(stringy) + 1
stringy = "Button" & integr
button.backcolor = white
end sub
Button1_Click
stringy = button1
procedureee
/*編輯*/
對不起,我認爲我沒有讓我的sefl清楚,一切都在此代碼對我的作品除了「字符串= Button1的」它說,串不能轉換爲system.windows.forms.button,但那正是我想要做的,我有一個程序有100個按鈕,當按下任何按鈕時,它將(「Dim local as button」)的值設置爲變量local =按鈕,它的作品,所以我採取該button.name並從它刪除1,所以我得到上面的按鈕的值(PS:我有一個網格上的按鈕,並垂直其f rom 1到10,如果我刪除1我得到按鈕的名稱abore ex:button1gA3成爲Button1gA2)但當我嘗試做到這一點local2 = stringy它給了我那個消息(字符串不能轉換爲system.windows.forms。按鈕)任何人都知道如何解決這個問題?
謝謝。