在访问表

时间:2017-11-27 08:27:16

标签: vba

我有一个访问表,我正在写一个vba代码从表中删除non-ascii个字符,我尝试使用以下两个函数

Public Function removeall(stringData As String) As String
    Dim letter As Integer
    Dim final As String
    Dim i As Integer

    For i = 1 To Len(stringData) 'loop thru each char in stringData

        letter = Asc(Mid(stringData, i, 1)) 'find the char and assign asc value

        Select Case letter 'Determine what type of char it is
            Case Is < 91 And letter > 64 'is an upper case char
                final = final & Chr(letter)
            Case Is < 123 And letter > 96 'is an lower case char
                final = final & Chr(letter)
            Case Is = 32  'is a space
                final = final & Chr(letter)
    End Select

    Next i
    removeall = final

    End Function

并尝试使用以下功能

Public Function Clean(InString As String) As String
'-- Returns only printable characters from InString
   Dim x As Integer
   For x = 1 To Len(InString)
      If Asc(Mid(InString, x, 1)) > 31 And Asc(Mid(InString, x, 1)) < 127 Then
         Clean = Clean & Mid(InString, x, 1)
      End If
   Next x

End Function

但问题是:在removeall function中,它删除了包括#space个字符在内的所有内容。而Clean function中的special characters也删除了[self.view addSubview:nib]; [self.view addSubview:button]; 。< / p>

我需要一个保留键盘字符并删除所有其他字符的正确功能

表格中的字符串示例如下:

1)“附着饲料管适合5-18ºFR#”

2)“CATHETER FOLEY 3WAY SILI ELAST 20FR30MLLATEXº”

非常感谢任何帮助

输出应该像

1)“连接喂养管适合5-18 FR”

2)“CATHETER FOLEY 3WAY SILI ELAST 20FR 30ML LATEX”

0 个答案:

没有答案