追蹤
ˊ-橙色九月-ˊ
關於部落格
  • 33533

    累積人氣

  • 0

    今日人氣

    0

    追蹤人氣

VB9

Priuate Sub Command1_Click()
'********************
'940301 program start
'********************

Private Sub Command1_Click()
Dim n As Integer  '原始資料
Dim n2 As Integer '計算用
Dim s As String   '計算用
Dim s1 As String  '結果
Open "d:940301.sm" For Input As #1
Input #1, n
Close #1
n2 = n
'使用 for 迴圈
For i = 1 To 99
 s = s & (n2 Mod 10)
 n2 = (n2 - (n2 Mod 10)) / 10
 If n2 = 0 Then Exit For
Next
''使用 Do while ... Loop
'Do While n2 > 0
' s = s & (n2 Mod 10)
' n2 = (n2 - (n2 Mod 10)) / 10
'Loop
''使用 Do ... Loop while
'Do
' s = s & (n2 Mod 10)
' n2 = (n2 - (n2 Mod 10)) / 10
'Loop While n2 > 0
If n / s = 1 Then
 s1 = n & " is a palindrome"
Else
 s1 = n & " is not a palindrome"
End If

Text1.text="第一題結果:" & s1
End Sub

改用Do while loop  =>計算
Do while n2 >= 0
s=s & (n2 Mod 10)
n2=(n2-(n2 Mod 10))/10
Loop
相簿設定
標籤設定
相簿狀態