复制在文本框(text)上的信息有空格,怎么去掉,trim可以去掉手输的,不能去掉复制上空格
我用len调试
复制的信息多两个栏位
比如 text1=A123114
应该 len(text1)=7
复制上去的就是 len(text1)=9,用trim也没用.
[解决办法]
循环这个字符串,debug.print那二个字符的ascii码,然后用replace替换
[解决办法]
估计是回车换行之类,用下面的代码确认一下
Dim s As String, i As Longs = Text1For i = 1 To Len(s) Debug.Print Asc(Mid$(s, i, 1))Next'对应方法s = Text1s = Replace(s, vbcr, vbnullstring)s = Replace(s, vblf, vbnullstring)s = trim(s)debug.print len(s)
[解决办法]
Private Sub Command1_Click()Dim strA As StringstrA = Replace(Text1.Text, "复制到这里", "") '把你多的两个栏位复制到" "中text2.Text = strAEnd Sub