1樓:
if text_gotfocus then text(index).backcolor = vbred
if text_lostfocus then text(index).backcolor = vbwhite
這種寫法是不行的!
vb是事件驅動語言。
所以,你應該寫作(當然你必須的有一個控制元件陣列叫做text):
private sub text_gotfocus(index as integer)
text(index).backcolor = vbredend sub
其餘依次類推
2樓:匿名使用者
只能用前面的方法,如果一定要用函式判斷可以這樣dim i as integer
private sub text1_gotfocus(index as integer)
i=index
end sub
private sub text1_lostfocus(index as integer)
i=-1
end sub
public function changecolor(text as textbox) '自定義函式-得焦點變色,失焦點恢復
if text.index=i then
text.backcolor = vbredelse
text.backcolor = vbwhiteendif
end function
changecolor (text1(1))
3樓:
既然是事件
那就用sub
自定義Excel函式,Excel中怎樣自定義函式
首先確認單元格中無空格,若有,查詢替換掉。方法1 結果在輔助列b列顯示。在b1輸入 if len a1 2 lenb a1 5,超過 len a1 2 lenb a1 下拉。或者 if len a1 2 lenb a1 5,len a1 2 lenb a1 超過 len a1 2 lenb a1 方...
matlab自定義函式function中輸入引數中有函式怎麼
天蠍神經俠侶 matlab自定義函式的六種方法 n1 函式檔案 呼叫函式 命令 檔案 需單獨定義一個自定義函式的m檔案 n2 函式檔案 子函式 定義一個具有多個自定義函式的m檔案 n3 inline 無需m檔案,直接定義 n4 匿名函式 n5 syms subs 無需m檔案,直接定義 n6 字串 s...
C語言中能否在自定義函式中呼叫另自定義函式
風若遠去何人留 可以呼叫。c語言最基本的模組為函式,任意函式都可以呼叫其它任意一個函式,包括函式本身。1 自定義函式呼叫其它自定義函式的例子 include void fun1 int a 自定義函式fun1。void fun2 int m,int n 自定義函式fun2。int main 在這個例...