。
教學範例《2》…計算圓周長與圓面積(2)
表單設計與程式執行:
| 表單設計 |
|---|
![]() |
| 執行畫面 |
![]() |
控制項屬性資料:
Form1 : 調整表單視窗的大小,使Width和Height合乎適當大小。 Label1 : Caption "圓半徑=" Label2 : Caption "圓周長=" Label3 : Caption "圓面積=" Text1: Alignment "2-置中對齊",Text "" Text2: Alignment "2-置中對齊",Text "" Text3: Alignment "2-置中對齊",Text "" |
程式碼列表:
Private Sub Command1_Click() End End Sub Private Sub Text1_Change() PI = 3.1416 R = Val(Text1.Text) C = 2 * PI * R A = PI * R ^ 2 Text2.Text = Str(C) Text3.Text = Str(A) End Sub |
程式解說:
|