WeGievU.Com
WeGievU.Com
WeGievU.Com
User :
Pass :
  WeGievU.Com
WeGievU.Com
WeGievU.Com
» E-Learning Room > Asp
WeGievU.Com
Control Structures For 
( 20  Views )

Mon 01-09-2551 Time 12:30
Category: Asp/ WeGievU.Com 0Comments
WeGievU.Com

วนลูบ for

for  เป็นคำสั่งสร้างเงื่อนไขให้ทำงานวนรอบซ้ำๆกัน จนกว่าตัวแปรที่กำหนดจะมีค่าครบตามเงื่อนไข โดยจะนำเอาเรื่องของการกำหนดค่าให้กับตัวแปรหรือAssignment Operators เข้ามาเกี่ยวข้องด้วย  การ Assignment   ค่าให้กับ  Operators ก็คือการสร้างเงื่อนไขและกำหนดค่าให้กับตัวแปรเป็นค่าต่างๆ จนครบที่กำหนด

 

รูปแบบคำสั่ง

 

for เงือนไข

งานที่จะต้องทำ

Next

ตัวอย่าง

for.asp

<html>
<head>
<title>Gangza</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
</head>

<body>
<%
for counter = 1 To 4

Response.write("<font color=red size=+" & counter & " >WeGiveU<br></font>")

Next
%>
</body>
</html>

ผลลัพธ์

WeGiveU
WeGiveU
WeGiveU
WeGiveU

คำอธิบาย

กำหนดให้ count มีค่าตั้งแต่ 1 ถึง 4

และให้พิมพ์คำว่า WeGiveU  ขนาดตัวอักษร ตั้งแต่ 1 จนถึง 4 โดยเว้นบรรทัด

******************************************
ลองดัดแปลงการใช้ดูเอานะครับ


แสดงความคิดเห็น “ Control Structures For   Comment”
WeGievU.Com
WeGievU.Com


Learning
| Tip | Knowledge
Copyright (c) 2010 by Wegiveu.com Team ( We Give Everything )