...
Lv 6
... 發問時間: 電腦與網際網路程式設計 · 1 0 年前

程式碼解釋

Private Sub init()

Dim v1, v2, t1, t2, a As Single

If Label3.Visible = True Then

m = Val(TextBox2.Text)

a = Val(TextBox3.Text)

sum = m * a

Else

m = Val(TextBox2.Text)

v1 = Val(TextBox4.Text)

v2 = Val(TextBox5.Text)

t1 = Val(TextBox6.Text)

t2 = Val(TextBox7.Text)

sum = m * (v2 - v1) / (t2 - t1)

End If

End Sub

--------------------------------------

Private Sub ToolBar1_ButtonClick(ByVal sender As System.Object, ByVal e As System.Windows.Forms.ToolBarButtonClickEventArgs) Handles ToolBar1.ButtonClick

Select Case ToolBar1.Buttons.IndexOf(e.Button)

Case 0

Call menuitem2_start()

Case 1

Call menuitem3_start()

End Select

init()

End Sub

---------------------------------------------------

1 個解答

評分
  • 1 0 年前
    最佳解答

    ' 初始規劃

    Private Sub init()

    Dim v1, v2, t1, t2, a As Single ' 定義變數

    If Label3.Visible = True Then ' 判斷 Label3 是否可見

    ' 可見執行

    m = Val(TextBox2.Text)

    a = Val(TextBox3.Text)

    sum = m * a

    Else

    ' 不可見執行

    m = Val(TextBox2.Text)

    v1 = Val(TextBox4.Text)

    v2 = Val(TextBox5.Text)

    t1 = Val(TextBox6.Text)

    t2 = Val(TextBox7.Text)

    sum = m * (v2 - v1) / (t2 - t1)

    End If

    End Sub

    --------------------------------------

    ' 工具列

    Private Sub ToolBar1_ButtonClick(ByVal sender As System.Object, ByVal e As System.Windows.Forms.ToolBarButtonClickEventArgs) Handles ToolBar1.ButtonClick

    Select Case ToolBar1.Buttons.IndexOf(e.Button)

    Case 0 ' 按鈕 0

    Call menuitem2_start()

    Case 1 ' 按鈕 1

    Call menuitem3_start()

    End Select

    init() ' 執行初始規劃副程式

    End Sub

    ---------------------------------------------------

還有問題?馬上發問,尋求解答。