ผลต่างระหว่างรุ่นของ "ภาษาปาสกาล"

จากวิกิพีเดีย สารานุกรมเสรี
เนื้อหาที่ลบ เนื้อหาที่เพิ่ม
ไม่มีความย่อการแก้ไข
บรรทัด 12: บรรทัด 12:
โปรแกรมการหาระยะห่างระหว่างจุด
โปรแกรมการหาระยะห่างระหว่างจุด


DIM A as [[integer]], b as integer, C as integer, D as integer
DIM A as [[integer]], b as integer, C as integer, D as integer
A = txt1.text
A = txt1.text
B = txt2.text
B = txt2.text
C = txt3.text
C = txt3.text
D = txt4.text
D = txt4.text
result = ((A-B)^2 + (C-D)^2)^0.5
result = ((A-B)^2 + (C-D)^2)^0.5
result = cal.caption
result = cal.caption


==ตัวอย่างการใช้คำสั่ง DIM ในโปรแกรม ไฮโล==
==ตัวอย่างการใช้คำสั่ง DIM ในโปรแกรม ไฮโล==

รุ่นแก้ไขเมื่อ 01:57, 21 กันยายน 2548

ภาษาปาสกาล (Pascal programming language) เป็นภาษาโปรแกรมที่ใช้กันอย่างกว้างขวาง โดยเฉพาะในวงการศึกษา คิดค้นขึ้นโดย นิเคลาส์ แวร์ท (Niklaus Wirth) นักวิทยาศาสตร์คอมพิวเตอร์ชาวสวิตเซอร์แลนด์ ในปี ค.ศ. 1970 เพื่อช่วยในการเรียนการสอนการเขียนโปรแกรมโครงสร้าง (structured programming). ภาษาปาสกาลนั้นพัฒนาขึ้นมาจาก ภาษาอัลกอล (Algol), และชื่อปาสกาลนั้น ตั้งเพื่อเป็นเกียรติแก่ แบลส ปาสกาล (en:Blaise Pascal). นอกเหนือจากภาษาปาสกาลแล้ว, แวร์ทได้พัฒนา ภาษาโมดูลาทู (Modula-2) และ โอบีรอน (Oberon) ซึ่งมีโครงสร้างคล้ายกับภาษาปาสกาล แต่สามารถรองรับการเขียนโปรแกรมเชิงวัตถุ (object-oriented programming).

โครงสร้าง อย่างง่าย

program PascalProgram1(output);
begin
 writeln('text');
end.

หลักการเขียนโปรแกแกรมภาษา ปาสคาล(PASCAL)

DIM ใช้การนิยามตัวแปร เช่นนิยามตัวแปร A,B,C,D

โปรแกรมการหาระยะห่างระหว่างจุด

DIM A as integer, b as integer, C as integer, D as integer
A = txt1.text
B = txt2.text
C = txt3.text
D = txt4.text
result = ((A-B)^2 + (C-D)^2)^0.5
result = cal.caption

ตัวอย่างการใช้คำสั่ง DIM ในโปรแกรม ไฮโล

Option Explicit

Private Sub cmdExit_Click() End End Sub

Private Sub cmdRollDice_Click() Dim result As Integer Dim total As Integer

imgCoin.Visible = False Randomize result = Int((6 * Rnd) + 1) lblDice1.Caption = result

result = Int((6 * Rnd) + 1) lblDice2.Caption = result

result = Int((6 * Rnd) + 1) lblDice3.Caption = result

total = CInt(lblDice1.Caption) + CInt(lblDice2.Caption) + CInt(lblDice3.Caption) lblTotal.Caption = total

Select Case total Case Is > 11 lblResult.Caption = "HIGH" If optHigh.Value Then imgCoin.Visible = True End If Case Is < 11 lblResult.Caption = "LOW" If optLow.Value Then imgCoin.Visible = True End If Case 11 lblResult.Caption = "HI-LO" If optHiLo.Value Then imgCoin.Visible = True End If End Select End Sub


Private Sub Form_Load()

End Sub

Private Sub imgCoin_Click()

End Sub

Private Sub Label1_Click()

End Sub

Private Sub Label2_Click()

End Sub

Private Sub lblDice1_Click()

End Sub

Private Sub lblDice2_Click()

End Sub

Private Sub lblDice3_Click()

End Sub

Private Sub lblResult_Click()

End Sub

Private Sub lblTotal_Click()

End Sub

Private Sub optHigh_Click()

End Sub

Private Sub optHiLo_Click()

End Sub

Private Sub optLow_Click()

End Sub