2012-08-30 25 views
79

VBA'da While ... Wend döngüsü kullanıyorum.Süre bitmeden dışarı ... Wend döngü

Dim count as Integer 

While True 
    count=count+1 

    If count = 10 Then 
     ''What should be the statement to break the While...Wend loop? 
     ''Break or Exit While not working 
    EndIf 
Wend 

ben `gibi koşulunu kullanmak istemiyorum < = 10 ... WEND

cevap

141

sayarken bir While/Wend sadece GOTO veya Exit sub (bir dış bloktan çıkarken tarafından zamanından önce çıkıldı edilebilir/function/another exitable loop)

Do loop intead;

Do While True 
    count = count + 1 

    If count = 10 Then 
     Exit Do 
    End If 
Loop 

(ya da artan bir dizi kontrol değişkeni döngü için)

for count = 1 to 10 
    msgbox count 
next