VB 既 copy function

2008-01-08 6:10 am
vb有冇類似copy既function??

如果我想read到每個字既letter/character係咩

應該點做?
更新1:

i mean the function of "RSet" 上網搵就係咁樣, rString = RSet(myString, 11) ' Returns " Right" 但係vb.6入面就run唔到 應該係點樣打既呢?

回答 (2)

2008-01-09 9:20 pm
✔ 最佳答案
系唔系甘樣:
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的意思)
2008-01-14 8:15 pm
copy function 在vb 是 mid function, 用法如下:
mid(original_string, starting_position, number_of_chars_copied)
e.g. a="qwert"
mid(a, 2, 1)="w"
mid(a, 3, 2)="er"


收錄日期: 2021-04-27 15:01:46
原文連結 [永久失效]:
https://hk.answers.yahoo.com/question/index?qid=20080107000051KK04218

檢視 Wayback Machine 備份