回覆列表
  • 1 # 程式設計頌

    "這題目對初學者,其實很有難度,執行效果如下

    Private Sub command1_click()

    Dim X As String

    Dim brr

    Dim a As Long

    Dim b As Long

    Dim c As Long

    X = InputBox("請輸入3個整數(以英文逗號分隔):", "求最大數", "例如:3,344,51", 1000, 1000)

    brr = Split(X, ",")

    If UBound(brr) > 2 Then

    MsgBox "輸入數字多餘3個,請重新輸入!", , "提醒"

    End "退出

    End If

    If UBound(brr)

    MsgBox "輸入數字少餘3個,請重新輸入!", , "提醒"

    End "退出

    End If

    a = brr(0)

    b = brr(1)

    c = brr(2)

    MsgBox "這三個數的最大數是" & Max(Max(a, b), c), , "最大數顯示"

    End Sub

    Function Max(n1 As Long, n2 As Long) As Long

    Max = IIf(n1 > n2, n1, n2)

    End Function

  • 中秋節和大豐收的關聯?
  • 年齡大就要快結婚麼?