close

==============此為廣告欄位,與文章內容無關==============


OPEN 小將暖暖蛋- 藍
OPEN 小將暖暖蛋- 藍

訂購網址:http://www.7net.com.tw/7net/rui005.faces?ID=111200142850&catid=13587&visit_chn=02&vid=ivip&mid=ivip_01&user=af000017132


==============此為廣告欄位,與文章內容無關==============

'專案>設定引用項目>Windows Script Host Object Model

Option Explicit

Private FSO As New FileSystemObject

Private Sub Command1_Click()
    Dim myStr As String
   
    myStr = FSO.OpenTextFile("D:\txt.txt", ForReading, False).ReadAll
    myStr = Replace(myStr, "張三", "李四")
    Call FSO.CreateTextFile("D:\txt2.txt", True).Write(myStr)
End Sub

Private Sub Command2_Click()
    'MsgBox Cut("ABCDEFGHIJKLMNOPQRSTUVWXYZ", 3, 5) 'Cut 第 3~5 個字
    'MsgBox Cut("ABCDEFGHIJKLMNOPQRSTUVWXYZ", 5) 'Cut 第 5 個字以後
    MsgBox Cut("ABCDEFGHIJKLMNOPQRSTUVWXYZ", "HIJ") 'Cut HIJ
End Sub

Private Function Cut(ByVal myStr As String, ByVal Start As String, Optional ByVal Ends = "") As String
    If IsNumeric(Start) = True And IsNumeric(Ends) = True Then
        Clipboard.Clear
        Clipboard.SetText Mid(myStr, Val(Start), Val(Ends) - Val(Start) + 1)
        Cut = Left(myStr, Val(Start) - 1)
        Cut = Cut & Right(myStr, Len(myStr) - Val(Ends))
    ElseIf IsNumeric(Start) = True Then
        Clipboard.Clear
        Clipboard.SetText Right(myStr, Len(myStr) - Val(Start) + 1)
        Cut = Left(myStr, Val(Start) - 1)
    Else
        Clipboard.Clear
       
        If InStr(myStr, "HIJ") <> 0 Then
            Clipboard.SetText Start
            Cut = Replace(myStr, Start, "")
        End If
    End If
End Function


參考資料 VB6 and Me
本文出自: http://tw.knowledge.yahoo.com/question/question?qid=1612020400080
今日特價


---------推薦每日奇摩購物中心好康商品-----------



本文內容引用自奇摩知識+,圖文版權為原所有人所有,如有任何侵權違規行為請馬上告知站長!將馬上處理!謝謝!
arrow
arrow
    全站熱搜

    郭可蓉 發表在 痞客邦 留言(0) 人氣()