用replace函数试试,将" "替换为empty。

解决方案 »

  1.   

    Text2 = Replace(Text1, " ", "")
    用这条语句,也就是用Replace这个函数就可以实现。
      

  2.   

    Private Sub Command1_Click()
    Dim s() As String, t As String, i As Long
    t = "a b c d e"
    s = Split(t, " ")
    t = ""
    For i = LBound(s) To UBound(s)
    t = t & s(i)Next
    Debug.Print t
    End Sub
      

  3.   

    其实TEXT1只用来输入人名,所以在样做也不错呀。
    在取得TEXT1中的值时:
    private sub command1_click()
    dim i as integer
    dim y as string 
    dim x as string
    for i=1 to len(trim(text1.text))
    y=mid(trim(text1.text),i,1)
    if y=" " then goto a:
    if y<>" " then
    x=x+y
    end if
    a:next i
    text2.text=x
    end sub
      

  4.   

    不让他输入空格就行了。
    if keyascii=32 then
       keyascii=0
    end if
    还可以把CTRL键屏蔽掉。。还有右键菜单这样做比较好
    自己做到。
    [email protected]
      

  5.   

    我也觉得在change事件中不让输入空格比较方便
      

  6.   

    text1.text=replace(text1.text," ","")
      

  7.   

    Private Sub txtName_KeyPress(KeyAscii As Integer)
        If KeyAscii = 32 Then
             KeyAscii = 0
        End If
    End Sub