若CheckBox預設值為0,程式碼為:
If Check1.Value=0 then
執行AAA
.......
.......
Else
執行BBB
.......
.......
End if
若將Check1.Value=0存檔,當程式啟動時將intCheckValue=0設給Check1.Value,因為Check1.Value=0為VB預設值,所以不執行Check1_Chick事件程序,也就是AAA沒執行到。
啟動時:
讀取Check1.Value存檔之值(如intCheckValue)
Check1.Value=intCheckValue 'intCheckValue=0 不執行Check1_Chick事件程序
若將Check1.Value=1存檔,當程式啟動時將intCheckValue=1設給Check1.Value則可執行Check1_Chick事件程序。
啟動時:
Check1.Value=intCheckValue '開始執行Check1_Chick事件程序
若將啟動時改為:
Check1.Value=intCheckValue
Check1_Chick
則intCheckValue=1時Check1.Value=intCheckValue會執行一次Check1_Chick事件程序,到Check1_Chick又執行一次同樣事件程序。這樣雖然不論存檔之intCheckValue值是否與預設相同但都可執行到Check1_Chick事件程序,問題是不管intCheckValue是否為預設值如何使之只執行一次事件程序?
arrow
arrow
    全站熱搜

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