Private Sub Form_Load() Me.Hide Open App.Path & "\in.txt" For Input As #1 Open App.Path & "\out.txt" For Output As #2 Input #1, x For i = 1 To x Line Input #1, y 'MsgBox asc(a) n = Len(y) For j = 1 To n a = Asc(Mid(y, j, 1)) If a >= 65 And a <= 90 Or a >= 97 And a <= 122 Then Sum = Sum + 1 End If Next Print #2, Sum Sum = 0 Next Close #2 Close #1 End End Sub
Dim s As Boolean Private Sub Form_Load() Me.Hide Open App.Path & "\in.txt" For Input As #1 Open App.Path & "\out.txt" For Output As #2 Input #1, n For i = 1 To n Line Input #1, x For j = 1 To Len(x) m = Asc(Mid(x, j, 1)) s = True For k = 0 To 9 If m = Asc(k) Then s = False: Exit For Next k If s = True Then t = t + 1 Next j Print #2, t t = 0 Next i Close Close End End Sub
Dim mycount, ans As Integer Dim strr As String Private Sub Form_Load() Me.Hide Open App.Path & "\in.txt" For Input As #1 Open App.Path & "\out.txt" For Output As #2 Input #1, mycount Do Input #1, strr For i = 97 To 122 ori = Len(strr) strr = Replace(strr, Chr(i), "") strr = Replace(strr, Chr(i - 32), "") ans = ans + ori - Len(strr) Next Print #2, ans: ans = 0 Loop Until EOF(1) Close #2 Close #1 End End Sub
Dim s As Boolean Private Sub Form_Load() Me.Hide Open App.Path & "\in.txt" For Input As #1 Open App.Path & "\out.txt" For Output As #2 Input #1, n For i = 1 To n Line Input #1, x x = LCase(x) For J = 1 To Len(x) m = Asc(Mid(x, J, 1)) s = True For K = Asc("a") To Asc("z") If m = K Then s = False: Exit For Next If s = False Then t = t + 1 Next J Print #2, t t = 0 Next i Close Close End End Sub
Dim mycount As Integer
回覆刪除Dim strr As String
Private Sub Form_Load()
Open App.Path & "\in.txt" For Input As #1
Open App.Path & "\out.txt" For Output As #2
Input #1, mycount
For i = 1 To mycount
Input #1, strr
strr = Replace(strr, "0", "")
strr = Replace(strr, "1", "")
strr = Replace(strr, "2", "")
strr = Replace(strr, "3", "")
strr = Replace(strr, "4", "")
strr = Replace(strr, "5", "")
strr = Replace(strr, "6", "")
strr = Replace(strr, "7", "")
strr = Replace(strr, "8", "")
strr = Replace(strr, "9", "")
Print #2, Len(strr)
Next
Close #2
Close #1
End Sub
Private Sub Form_Load()
回覆刪除Me.Hide
Open App.Path & "\in.txt" For Input As #1
Open App.Path & "\out.txt" For Output As #2
Input #1, x
For i = 1 To x
Line Input #1, y
'MsgBox asc(a)
n = Len(y)
For j = 1 To n
a = Asc(Mid(y, j, 1))
If a >= 65 And a <= 90 Or a >= 97 And a <= 122 Then
Sum = Sum + 1
End If
Next
Print #2, Sum
Sum = 0
Next
Close #2
Close #1
End
End Sub
Dim s As Boolean
回覆刪除Private Sub Form_Load()
Me.Hide
Open App.Path & "\in.txt" For Input As #1
Open App.Path & "\out.txt" For Output As #2
Input #1, n
For i = 1 To n
Line Input #1, x
For j = 1 To Len(x)
m = Asc(Mid(x, j, 1))
s = True
For k = 0 To 9
If m = Asc(k) Then s = False: Exit For
Next k
If s = True Then t = t + 1
Next j
Print #2, t
t = 0
Next i
Close
Close
End
End Sub
Bob&KiKi程式錯誤,要把中文也刪掉。
回覆刪除復陞程式正確,也可以把字串用成同一大小寫,判斷會少兩個。
另外標點符號也需要刪掉。
Dim mycount, ans As Integer
回覆刪除Dim strr As String
Private Sub Form_Load()
Me.Hide
Open App.Path & "\in.txt" For Input As #1
Open App.Path & "\out.txt" For Output As #2
Input #1, mycount
Do
Input #1, strr
For i = 97 To 122
ori = Len(strr)
strr = Replace(strr, Chr(i), "")
strr = Replace(strr, Chr(i - 32), "")
ans = ans + ori - Len(strr)
Next
Print #2, ans: ans = 0
Loop Until EOF(1)
Close #2
Close #1
End
End Sub
Dim s As Boolean
回覆刪除Private Sub Form_Load()
Me.Hide
Open App.Path & "\in.txt" For Input As #1
Open App.Path & "\out.txt" For Output As #2
Input #1, n
For i = 1 To n
Line Input #1, x
x = LCase(x)
For J = 1 To Len(x)
m = Asc(Mid(x, J, 1))
s = True
For K = Asc("a") To Asc("z")
If m = K Then s = False: Exit For
Next
If s = False Then t = t + 1
Next J
Print #2, t
t = 0
Next i
Close
Close
End
End Sub
程式正確
回覆刪除