字符串只有 英文单词 和 数字例如 asdakjh1j4h1haf把这样的数字转换为 
asdakjh_1_jh_1_haf也就是说数字的左右要变成  _数字_  这样的格式连续数字,就是 _1_2_3_   (不会出现连续2个_ _)

解决方案 »

  1.   


    Private Sub Command1_Click()
    Dim s$, ss$
    s = "asdakjh1j4h1haf"
    For i = 1 To Len(s)
        If IsNumeric(Mid(s, i, 1)) Then
            If Right(ss, 1) <> "_" Then ss = ss & "_"
            ss = ss & Mid(s, i, 1) & "_"
        Else
            ss = ss & Mid(s, i, 1)
        End If
    Next i
    MsgBox ss
    End Sub
      

  2.   

    Private Sub Form_Load()
    s = "asdakjh1j4h1haf"
    For i = 0 To 9
    s = Replace(s, i, "_" & i & "_")
    Next
    MsgBox s
    End Sub
      

  3.   


    Private Sub Command1_Click()
        Dim s As String, i As Integer
        s = "asdakjh1j4h1haf1234"
        For i = 0 To 9
            s = Replace(s, i, "_" & i & "_")
        Next
        s = Replace(s, "__", "_")
        MsgBox sEnd Sub