返回列表 上一主題 發帖

如何判斷FOR+IF迴圈的ELSE

如何判斷FOR+IF迴圈的ELSE

以下是FOR+IF迴圈當True的時候做~
For i = 19 To 36
    If Controls("OptionButton" & i) = True Then
    TextBox1 = TextBox1 & " " & Controls("OptionButton" & i).Caption & "〈" & CommandButton9.Caption & "〉"
    Controls("OptionButton" & i).Value = False
    Exit For
    End If
Next i
那如果都OptionButton都沒有被選取的時候做~我該怎麼寫?
我自行改寫後~失敗~如下
For i = 19 To 36
    If Controls("OptionButton" & i) = True Then
    TextBox1 = TextBox1 & " " & Controls("OptionButton" & i).Caption & "〈" & CommandButton9.Caption & "〉"
    Controls("OptionButton" & i).Value = False
    Exit For
    Else
    TextBox1 = CommandButton9.Caption
    End If
Next i

回復 1# av8d


    自行找出問題了~謝謝!

TOP

回復 2# av8d


    由於3分鐘內無法編輯~我在此繼續提問~

如何將Label3.Caption的內容取前面三個字?

如果我的Label3.Caption內容是A1.牛肉麵
一般我們下函數是Left~如果是要取Label3.Caption前三個字~
答案是A1.
我該如何取字?

TOP

回復  av8d


    由於3分鐘內無法編輯~我在此繼續提問~

如何將Label3.Caption的內容取前面三個字?
...
av8d 發表於 2012-7-29 23:14


...看不懂耶?
所以你是要取"A1." 還是"牛肉麵"

TOP

回復 3# av8d
Mid(Label3.Caption, 1, 3)
多查看VBA 說明,練習範例 會進步的

TOP

        靜思自在 : 是非當教育,讚美作警惕。
返回列表 上一主題