Dim str As String Private Sub Form_Load() Open App.Path & "\in.txt" For Input As #1 Open App.Path & "\out.txt" For Output As #2 Line Input #1, str Print #2, "(1):" & Len(str) str1 = Replace(str, "4", "4*號") Print #2, "(2):" & str1 str2 = Replace(str, "3", "3+號") Print #2, "(3):" & str2 str3 = Replace(str, "5", "5?號") Print #2, "(4):" & str3 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 Dim a, n As String Dim q As Boolean w = 0 Input #1, a w = Len(a) Print #2, w For i = w To 1 Step -1 q = False s = Mid(a, i, 1) If s = 4 Then l = Left(a, w - 5) r = Right(a, w - i) s = "4 *號" q = True End If If s = 3 Then l = Left(a, w - 3) r = Right(a, w - i) s = "3+號" q = True End If If s = 5 Then l = Left(a, w - 7) r = Right(a, w - i) s = "5?號" q = True End If If q = True Then Print #2, l & s & r Next Close #2 Close #1 End 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 Line Input #1, x Print #2, "(1):" & Len(x) Print #2, "(2):" & " " & Replace(x, "4", "4*號") Print #2, "(2):" & " " & Replace(x, "3", "3+號") Print #2, "(2):" & " " & Replace(x, "5", "5?號") Close Close End 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 Line Input #1, x Print #2, "(1):" & Len(x) Print #2, "(2):" & " " & Replace(x, "4", "4*號") Print #2, "(3):" & " " & Replace(x, "3", "3+號") Print #2, "(4):" & " " & Replace(x, "5", "5?號") Close Close End End Sub
Dim str As String
回覆刪除Private Sub Form_Load()
Open App.Path & "\in.txt" For Input As #1
Open App.Path & "\out.txt" For Output As #2
Line Input #1, str
Print #2, "(1):" & Len(str)
str1 = Replace(str, "4", "4*號")
Print #2, "(2):" & str1
str2 = Replace(str, "3", "3+號")
Print #2, "(3):" & str2
str3 = Replace(str, "5", "5?號")
Print #2, "(4):" & str3
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
Dim a, n As String
Dim q As Boolean
w = 0
Input #1, a
w = Len(a)
Print #2, w
For i = w To 1 Step -1
q = False
s = Mid(a, i, 1)
If s = 4 Then
l = Left(a, w - 5)
r = Right(a, w - i)
s = "4 *號"
q = True
End If
If s = 3 Then
l = Left(a, w - 3)
r = Right(a, w - i)
s = "3+號"
q = True
End If
If s = 5 Then
l = Left(a, w - 7)
r = Right(a, w - i)
s = "5?號"
q = True
End If
If q = True Then Print #2, l & s & r
Next
Close #2
Close #1
End
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
Line Input #1, x
Print #2, "(1):" & Len(x)
Print #2, "(2):" & " " & Replace(x, "4", "4*號")
Print #2, "(2):" & " " & Replace(x, "3", "3+號")
Print #2, "(2):" & " " & Replace(x, "5", "5?號")
Close
Close
End
End Sub
Bob & 復陞 程式正確。
回覆刪除復陞 下次試試函數吧
KiKi 忘了把(2) 改成 (3)、(4)
Private Sub Form_Load()
回覆刪除Me.Hide
Open App.Path & "\in.txt" For Input As #1
Open App.Path & "\out.txt" For Output As #2
Line Input #1, x
Print #2, "(1):" & Len(x)
Print #2, "(2):" & " " & Replace(x, "4", "4*號")
Print #2, "(3):" & " " & Replace(x, "3", "3+號")
Print #2, "(4):" & " " & Replace(x, "5", "5?號")
Close
Close
End
End Sub