。
表單設計 |
---|
![]() |
執行畫面 |
![]()
|
Form1 : 調整表單視窗的大小,使Width和Height合乎適當大小。 Label1 : Caption "A=" Label2 : Caption "B=" Label3 : Caption "A+B" Label4 : Caption "A-B" Label5 : Caption "A*B" Label6 : Caption "A/B" Label7 : Caption "機械系 二年甲班" Label8 : Caption "王小明 49602099" Text1: Alignment "2-置中對齊",Text "" Text2: Alignment "2-置中對齊",Text "" Text3: Alignment "2-置中對齊",Text "" Text4: Alignment "2-置中對齊",Text "" Text5: Alignment "2-置中對齊",Text "" Text6: Alignment "2-置中對齊",Text "" Frame1: Caption "四則運算" Command1: Caption "計算" Command2 Caption "結束" |
Private Sub Command1_Click() Dim A, B As Single A = Val(Text1.Text) B = Val(Text2.Text) C1 = A + B C2 = A - B C3 = A * B If B = 0 Then MsgBox "除法分母不可為零!", , "錯誤訊息" Else C4 = A / B End If Text3.Text = Str(C1) Text4.Text = Str(C2) Text5.Text = Str(C3) If B = 0 Then Text6.Text = "分母為0,錯誤!" Else Text6.Text = Str(C4) End If End Sub Private Sub Command2_Click() End End Sub |
|