请问如何在程序里修改textbox的内容,比如一个textbox的内容如下:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
file name:abc.txt
cccccccccccccccccccccccccccccccccccccccccccccccccccccc
dddddddddddddddddddddddddddddddddddddddddddddddddddddd如何写一段代码使file name:后边变为cde.txt,其它部分不变

解决方案 »

  1.   

    Private Sub Command1_Click()
    Text1.Text = Replace(Text1.Text, "abc.txt", "cde.txt")
    End Sub
      

  2.   

    text1.Text=left(text1.Text,instr(text1.text,"file name:")+len("file name:")) & "cde.txt"
      

  3.   

    '正解
     回复人: northwolves(狼行天下) ( ) 信誉:125  2005-10-14 23:55:00  得分: 0  
     
     
       Private Sub Command1_Click()
    Text1.Text = Replace(Text1.Text, "abc.txt", "cde.txt")
    End Sub
      
     
      

  4.   

    问题是那个filename不一定是abc.txt,我只是举个例子,它可能是???.???,所以不可以用找名字的方法找到它。请大家指点。
      

  5.   

    Dim pos1 As Long, pos2 As Long, pos3 As Long, strFileName As String
    pos1 = InStr(Text1.Text, "file name:") + Len("file name:")
    pos2 = InStr(Text1.Text, ".txt") + Len(".txt")
    LenfileName = pos2 - pos1
    strFileName = Mid(Text2.Text, pos1, LenfileName)
    Text1.Text = Replace(Text1.Text, strFileName,"cde.txt")
      

  6.   

    谢谢各位,但现在的为问题是那个“filename:”后边的文件名是未知的 我想把它换成cde.txt 
    所以 pos2 = InStr(Text1.Text, ".txt") + Len(".txt") 是不行的。
      

  7.   

    i=instr(text1,"file name:")'找到file name:的位置
    j=instr(i,text1,".")'从上面的位置开始找小数点
    str=mid(text1,i+10,j-i-10)'取得:和.之间的串
    text1=replace(text1,str & ".txt","cde.txt")'替换