頁:
[1]
select case搭配if使用需求問題
全域變數
sValue long
sub裡面
宣告一個變數為tValue int
tValue = test.text
Select case tValue
case is =33
sValue = 33
case is =44
sValue = 44
select end
if sValue = 33 and
tValue = 88 then
WirteValue 1.text= 1
end if
if sValue = 33 and
tValue = 88 then
WirteValue 2.text=1
end if
exit sub
select case tValue
case is =33
sValue = 33
case is =44
sValue = 44
select end
請問一下這樣程式哪邊該修 執行上會有問題
第一次讀到的值 如為33或44 存在全域變數
第二次讀到的值 如為88 就會跳到if判斷 讓WirteValue.text寫入1 這樣
...<div class='locked'><em>瀏覽完整內容,請先 <a href='member.php?mod=register'>註冊</a> 或 <a href='javascript:;' onclick="lsSubmit()">登入會員</a></em></div><div></div> 這是你要的嗎?
Select Case tValue
Case Is = 33
sValue = 33
Case Is = 44
sValue = 44
Case Is = 88
Select Case sValue
Case Is = 33
WirteValue 1.text= 1
Case Is = 44
WirteValue 2.text= 1
End Select
End Select
samou568 發表於 2015-3-27 08:16 AM static/image/common/back.gif
這是你要的嗎?
我晚點試試看
我要的邏輯就是
33 88 44 88 22 11
依序從左至右
一開始是0 當tValue讀到33時寫入sValue,再來會讀到88(tValue)
sValue = 33 and tValue = 88
WirteValue 1.text= 1
WirteValue 2.text= 0
sValue = 44 and tValue = 88
WirteValue 2.text= 1
WirteValue 1.text= 0
讀到下一不屬於 33 44 88的值時
WirteValue 1.text= 0
WirteValue 2.text= 0
這樣的變化
我寫得太多程式碼?...<div class='locked'><em>瀏覽完整內容,請先 <a href='member.php?mod=register'>註冊</a> 或 <a href='javascript:;' onclick="lsSubmit()">登入會員</a></em></div> 最好再加一個 Other 避免萬一輸入例外的的值造成程式當了 Jeepluo 發表於 2015-3-28 07:35 PM static/image/common/back.gif
最好再加一個 Other 避免萬一輸入例外的的值造成程式當了
有讀到其它的值?當掉??
不太懂!!<br><br><br><br><br><div></div> 就是說你使用 Select Case 的陳述式,卻沒有完整的表示出來,
語法如下:Select [ Case ] testexpression
[ Case expressionlist
[ statements ] ]
[ Case Else
[ elsestatements ] ]
End Select你卻寫成了這樣Select case tValue
case is =33
sValue = 33
case is =44
sValue = 44
select end萬一輸入的 tValue = 35 或 = 36 預估之外的值,那 sValue 要等於什麼值呢? 或是要提出警示呢?...<div class='locked'><em>瀏覽完整內容,請先 <a href='member.php?mod=register'>註冊</a> 或 <a href='javascript:;' onclick="lsSubmit()">登入會員</a></em></div>
頁:
[1]