在字符串中搜索符合条件的,该怎么处理

在字符串中搜索符合条件的PrivateSubCommand1_Click()DimstrTempAsStringstrTempaslkdjalksj32334j23j

在字符串中搜索符合条件的
Private       Sub       Command1_Click()      
                    Dim       strTemp       As       String      
                    strTemp       =       "aslkdjalksj32334j23j "      
                    Dim       i       As       Integer      
                    For       i       =       1       To       Len(strTemp)      
                                    If       IsCommonChar(Mid(strTemp,       i,       1))       =       False       Then      
                                                    MsgBox       "有非字母或数字的字符 "      
                                                    Exit       Sub      
                                    End       If      
                    Next      
                    MsgBox       "没有非字母或数字的字符 "      
                       
                    strTemp       =       "aslkdja@¥#!¥lksj32334j23j "      
                    For       i       =       1       To       Len(strTemp)      
                                    If       IsCommonChar(Mid(strTemp,       i,       1))       =       False       Then      
                                                    MsgBox       "有非字母或数字的字符 "      
                                                    Exit       Sub      
                                    End       If      
                    Next      


                    MsgBox       "没有非字母或数字的字符 "      
    End       Sub      
       
    Private       Function       IsCommonChar(strChar       As       String)       As       Boolean      
                    If       (Asc(strChar)       > =       48       And       Asc(strChar)       <=       57)       _      
                                    Or       (Asc(strChar)       > =       65       And       Asc(strChar)       <=       90)       _      
                                    Or       (Asc(strChar)       > =       97       And       Asc(strChar)       <=       122)       Then      
                                    IsCommonChar       =       True      
                    Else      
                                    IsCommonChar       =       False      
                    End       If      
    End       Function
以上代码可以判断是否有非字母和数字,如果有,我想得到那些非字母数字的字符,怎么个写法?刚接触VB,大家救救我啊!!

[解决办法]
拿个篮子把它们装起来:)

再定义一个字符串变量来做篮子:

dim OutStr as string,MidStr as string

把你的循环判断过程改一下:

For i = 1 To Len(strTemp)
midstr=Mid(strTemp, i, 1)
If IsCommonChar(midstr) = False Then
outstr=outstr & midstr
End If
Next

outstr里面就是你想要的东西了.
[解决办法]
For i = 1 To Len(strTemp)
midstr=Mid(strTemp, i, 1)
If IsCommonChar(midstr) = False Then
outstr=outstr & midstr
End If
Next