✔ 最佳答案
系唔系甘樣:
Dim strTest As String
Dim i As Integer
strTest = "Hello,World"
MsgBox "String length=" & Len(strTest), vbInformation, strTest
For i = 1 To Len(strTest)
MsgBox "The " & i & StNdRdTh(i) & " character is " & Mid$(strTest, i, 1)
Next
'自己寫左個Function轉th、st果D
Function StNdRdTh(n As Integer) As String
If n = 11 Or n = 12 Or n = 13 Then
StNdRdTh = "th"
Exit Function
Else
Select Case Right$(CStr(n), 1)
Case 1
StNdRdTh = "st"
Case 2
StNdRdTh = "nd"
Case 3
StNdRdTh = "rd"
Case Else
StNdRdTh = "th"
End Select
End If
End Function
2008-01-09 13:23:15 補充:
上面系統將部分引號轉左做",請自行修改返
2008-01-15 20:54:27 補充:
順便提返,指定mid函數的返回類型會提高執行效率(即使用mid$(原本既string,位置——由1開始,取字數量),$就是指定返回String的意思)