Rss & SiteMap

Foxtable(狐表) http://www.foxtable.com

新一代数据库软件,完美融合Access、Foxpro、Excel、vb.net之优势,人人都能掌握的快速软件开发工具!
共16 条记录, 每页显示 10 条, 页签: [1] [2]
[浏览完整版]

标题:替换

1楼
blackzhu 发表于:2011/9/5 11:01:00
Dim Str1 As String = forms("代码编辑器").Controls("TextBox1").Value
Dim Str2 As String = forms("替换和查找").Controls("TextBox1").Value
Dim str3 As String = forms("替换和查找").Controls("TextBox2").Value


    三个TexTbox控件,我想在STR2中给出一个字符串,找到STR1相对应的字符串,并利用STR3给出的字符串替换掉.

说到底就是代码编辑器中的查找和替换按钮中那个东西.怎么做?
2楼
狐狸爸爸 发表于:2011/9/5 11:46:00

str2 = str2.replace(str1,str3)

forms("替换和查找").Controls("TextBox2").Value = Str2

 

3楼
blackzhu 发表于:2011/9/5 12:41:00
全部替换掉?这个我会,我要的是字符串,
举例STR1一句forms("窗口1").OPEN(),我在Dim Str2 As String = forms("替换和查找").Controls("TextBox1").Value中输入"OPEN",在Dim str3 As String = forms("替换和查找").Controls("TextBox2").Value输入CLOSE,按替换,将OPEN替换成CLOSE.
4楼
kylin 发表于:2011/9/5 13:39:00

找到STR1相对应的字符串,参考:

字符串的IndexOf

 

相关的具体内容看帮助

5楼
blackzhu 发表于:2011/9/5 14:28:00
搞定了,我用的是Contains

Dim Str1 As String =forms("代码编辑器").Controls("TextBox1").Value
Dim Str2 As String = forms("替换和查找").Controls("TextBox1").Value
If Str1.Contains(Str2) Then
 
   怎么定位找的字符串.
   
End If
6楼
blackzhu 发表于:2011/9/5 15:21:00
Dim c1,c2 As WinForm.TextBox
c1 = Forms("代码编辑器").controls("textbox1")
c2 = e.Form.controls("textbox1")
Dim t1,t2,t3 As String
t1=c1.value
t2=c2.value
t3 =iif(t2 = "","请输入要查找的字符!",iif(Instr(t1,t2) = 0,"没有找到!",""))
If t3  = "" Then
    c1.Select()
    c1.SelectionStart = Instr(t1,t2)-1
    c1.SelectionLength = Len(t2)
Else
    MessageBox.Show(t3, "提示",MessageBoxButtons.ok, MessageBoxIcon.Question)
End If

  这段代码为什么异窗口不行,本窗口可以显示
7楼
blackzhu 发表于:2011/9/5 16:18:00
怎么不行呢?
8楼
blackzhu 发表于:2011/9/5 16:32:00
老大帮忙看看,怎么在本窗口可以,但是异窗口不行呢?

If forms("代码编辑器").Opened
    Dim t1,t2 As String
    t1=Forms("代码编辑器").Controls("TextBox1").text
    t2=Forms("替换和查找").Controls("TextBox1").text
    Forms("代码编辑器").Controls("TextBox1").Select()
    If t2 <> "" Then
        If Instr(t1,t2) <> 0 Then
            Forms("代码编辑器").Controls("TextBox1").SelectionStart = Instr(t1,t2)-1
            Forms("代码编辑器").Controls("TextBox1").SelectionLength = Len(t2)
        Else
            MessageBox.Show("没有找到!", "提示", MessageBoxButtons.ok, MessageBoxIcon.Question)
        End If
    Else
        MessageBox.Show("请输入要查找的字符!", "提示", MessageBoxButtons.ok, MessageBoxIcon.Question)
    End If
End If

  这样也不行
9楼
狐狸爸爸 发表于:2011/9/5 16:38:00
没有道理的,做个例子上来吧,这样好分析。
10楼
紙上不談兵 发表于:2011/9/5 16:46:00
现在大家都喜欢:纸上谈兵!
共16 条记录, 每页显示 10 条, 页签: [1] [2]

Copyright © 2000 - 2018 foxtable.com Tel: 4000-810-820 粤ICP备11091905号

Powered By Dvbbs Version 8.3.0
Processed in .06006 s, 2 queries.