Private Declare Function GetSystemDirectory Lib "kernel32" Alias "GetSystemDirectoryA" (ByVal lpBuffer As String, ByVal nSize As Long) As Long
Private Sub Form_Load()
    Dim Sysdir As String, x As Long, x4 As Long
    Sysdir = Space(20)
    x = GetSystemDirectory(Sysdir, 20)
    x4 = Len(Sysdir)
    Label2.Caption = x4
    Label1.Caption = "keu" & Trim(Sysdir) & "\abc"
End Sub结果显示:keuC:\WINDOWS\SYSTEM
而\abc却没有显示?
使用TRIM(SYSDIR)函数也没用 我该怎么去掉字符串里的space呢?

解决方案 »

  1.   

    Label1.Caption = Replace("keu" & Trim(Sysdir) & "\abc",chr(0),vbnullstring)
      

  2.   

    dim str as string
    str="  张    三   "
    str=replace(str,space(1),space(0))
    debug.print str    '结果为:张三
      

  3.   

    Private Declare Function GetSystemDirectory Lib "kernel32" Alias "GetSystemDirectoryA" (ByVal lpBuffer As String, ByVal nSize As Long) As Long
    Private Sub Form_Load()
        Dim Sysdir As String, x As Long, x4 As Long
        Sysdir = Space(20)
        x = GetSystemDirectory(Sysdir, 20)
        x4 = Len(Sysdir)
        Label2.Caption = x4
        Label1.Caption = Replace("keu" & Trim(Sysdir) & "\abc", Chr(0), vbNullString)
    End Sub