# vb 兩位數的阿姆斯壯數(急)

1. 兩位數的阿姆斯壯數:

（答案：沒有）

AB=A^2+B^2

2.寫一程式找出一個最小的三位整數，其二個數字的平方和正好等於該數減去100 (即135)

XYZ-100=X^2+Y^2+Z^2

3.假設電力公司的電費計算依累進方式，如下:

100度以下部分，每度2.4元

101~300度部分，每度3.1元

301度以上部分，每度4.1元

4.寫一程式輸入一串資料，計算其中TH出現的次數。

5.寫一程式輸入一串資料，將其中空白字元去除後輸出。

Rating
• W.J.S.
Lv 7

Private Sub Command1_Click() '第1題

Dim I As Integer

For I = 10 To 99

If Left(I, 1) ^ 2 + Right(I, 1) ^ 2 = I Then Print I

Next

End Sub

Private Sub Command2_Click() '第2題

Dim I As Integer, S As String

For I = 100 To 999

If I - 100 = Left(I, 1) ^ 2 + Mid(I, 2, 1) ^ 2 + Right(I, 1) ^ 2 Then

Print I: Exit For

End If

Next

End Sub

Private Sub Command3_Click() '第3題

Dim S As String, N As Integer

Do

S = InputBox("請輸入用電度數")

If S = "" Then Exit Sub

If IsNumeric(S) Then

If Int(Val(S)) > -1 Then Exit Do

End If

Loop

N = S

Select Case N

Case Is < 101: Print "應繳金額" & N * 2.4; "元"

Case 101 To 300: Print "應繳金額" & N * 3.1; "元"

Case Is > 300: Print "應繳金額" & N * 4.1; "元"

End Select

End Sub

Private Sub Command4_Click() '第4題

Dim S As String

S = InputBox("請輸入字串", , "THERE ARE THREE MONTH")

If S = "" Then Exit Sub

Print UBound(Split(S, "TH"))

End Sub

Private Sub Command5_Click() '第5題

Dim S As String

S = InputBox("請輸入字串", , "THANK YOU VERY MUCH")

If S = "" Then Exit Sub

Print Replace(S, " ", "")

End Sub

Source(s): WJS

第三題：

d = InputBox("請輸入電度數")

Select Case d

Case Is <= 100

Print "本期應繳" & (2.4) * d & "元"

Case 101 To 300

Print "本期應繳" & (3.1) * d & "元"

Case Is > 300

Print "本期應繳" & (4.1) * d & "元"

End Select

Source(s): 鶯歌高職 資楚科科會長