ªð¦^¦Cªí ¤W¤@¥DÃD µo©«

¦³ÃöExcel vba¤¤ªºDo Loop¤£¤Ó©ú¥Õ

¦³ÃöExcel vba¤¤ªºDo Loop¤£¤Ó©ú¥Õ

¦³ÃöExcel vba¤¤ªºDo Loop¤£¤Ó©ú¥Õ
·s¤â¾Ç²ß ¤£¤Ó·|¥ÎDo Loop

À³¸Ó¦p¦ó¦bExcel vba¤¤¥ÎDo Loop ½s¼g¥H¤U±¡ªp

­º¥ý¦³¤@ºâ¦¡
b=a+20-40+5
a¬O¤@­Ó¼Æ­È, ²{¦b·Q¨D¥Xa¬O¦h¤Ö, ¤~·|¨Ïb=0

¤@¶}©l§Ú¬O¤£ª¾¹Daªº­È¬O¦h¤Ö ¥u¬OÀH«K¿é¥X¤@¼Æ­È ¨Ò¦pa=4
±N³o­Óa=4¥N¤J¼Æ¦¡b=a+20-40+5
¦pªG±o¥Xªºb¬O¤j©ó¤Î¤Ö©ó¹s(b>0, b<0) ªº®É­Ô
¥¦¯àÀ°§Ú¤£Â_¹Á¸Õa=¥t¤@­Ó¼Æ­È, ±q¦Ó¨D¥Xa¬O¦h¤Ö·|¨Ïb=0
·í±o¥Xb=0ªº®É­Ô
¥¦¤S·|¶i¤J¤U¤@¨B
¨Ò¦p ­pºâ: c=b+10

½ÐÀ°¦£
ÁÂÁÂ

¦^´_ 1# drgv11

³o¼Ë¹ï¶Ü¡H
  1. Sub test()
  2. a = 0
  3. b = 20 - 40 + 5
  4. Do Until a + b = 0
  5. If b >= 0 Then a = a - 1
  6. If b <= 0 Then a = a + 1
  7. Loop
  8. c = a + 10
  9. MsgBox c
  10. End Sub
½Æ»s¥N½X

TOP

¦^´_ 2# owen06

ÁÂÁ¤j¤j

TOP

¦^´_ 2# owen06
¤j¤j
¦pªG  b=a¡Ñsin45¢X-20
À³¸Ó«ç¼Ë¼g??

TOP

¤F¸Ñ
À³¸Ó­n¶R¤@¥»VBA®ÑÄy
ÁÂÁÂ

TOP

¦^´_ 4# drgv11

Do ... Loop Á|¨Òºt¥Ü:
  1. Option Explicit

  2. Sub DoLoopTest()
  3. Dim a#, b#, h#
  4. Dim Rad#, c#
  5. Dim iter%, IterMax%
  6. Const e = 0.00000001        '»~®t³\¥i­È
  7. Const Pi = 3.14159265358979

  8. IterMax = 500               '³Ì°ª·j´M­¡¥N¼Æ

  9. Rad = Pi * 45 / 180

  10. a = 100     'ªì©l­È
  11. h = 5       'ªì©l·j´M¨Bªø
  12. Do
  13.     b = a * Sin(Rad) - 20
  14.     If Abs(b) < e Then Exit Do      '¯BÂI¼Æ¹Bºâ«ÜÃø±o¨ì§¹¥þ¬Ûµ¥
  15.     If b > 0 Then
  16.         a = a - h
  17.     Else
  18.         h = h * 0.5
  19.         a = a + h
  20.     End If
  21.     iter = iter + 1
  22. Loop While iter < IterMax    'µL¸Ñ®É¥i¥H¸õ¥X °j°é
  23. Debug.Print
  24. Debug.Print "  iter = " & iter
  25. Debug.Print "Ans. a = " & a
  26. Debug.Print "     h = " & h
  27. End Sub
½Æ»s¥N½X

TOP

        ÀR«ä¦Û¦b : Ä@­n¤j¡B§Ó­n°í¡B®ð­n¬X¡B¤ß­n²Ó¡C
ªð¦^¦Cªí ¤W¤@¥DÃD