可能是本人的语言表达能力有问题.刚才的问题问的错了.简单的问一下吧.有一个字符串.最后几位(不确定的)是数字,例如aaa12,想怪出12怎么取,在线等待....

解决方案 »

  1.   

    Private Sub Form_Load()
    Dim str, strtemp As String
    Dim i As Integer
    str = "aaa12"
    For i = 1 To Len(str)
        If IsNumeric(Mid(str, i, 1)) Then strtemp = strtemp & Mid(str, i, 1)
    Next
    MsgBox strtemp
    End Sub
      

  2.   

    晕~刚才回答你问题的各位没有理解错啊,现在我看你这个问题还是和刚才一个意思如果你的字符串前面的字母长度是固定的,可以这样
    msgbox right(你的字符串,len(你的字符串)-前面字母的长度)
    比如:
    你的字符串是"aaa123"
    msgbox right("aaa123",len("aaa123")-3)
      

  3.   

    不解释了,程序很简单,自己看吧:
    Option ExplicitPrivate Sub Command1_Click()
        Dim s As String
        s = "aaaa1234567"
        MsgBox getnum(s)
    End SubPrivate Function getnum(ByVal mStr As String) As Long
        Dim i As Long
        i = Len(mStr)
        Dim s As String, ss As String
        Dim j As Long
        If i = 0 Then
            getnum = 0
            Exit Function
        End If
        For j = 1 To i
            s = Right(mStr, j)
            If Val(s) = 0 Then
                Exit For
            End If
            ss = s
        Next
        getnum = Val(ss)
    End Function
      

  4.   

    Dim S As String
    S = "aaaa12"
    Msgbox Val(StrReverse(Format(Val(StrReverse(S)))))
      

  5.   

    //比你想的还周全:)你没考虑到最后一位数字是0的可能性~
    呵呵,当然考虑到了。见http://community.csdn.net/Expert/topic/3106/3106669.xml?temp=.4202845哈哈,还是要在这里Sorry一下
      

  6.   

    我才傻呢,本来我是倒过来之后用asc()看是不是=48,如果是,则最后是0,就把结果*10,结果有两个0时又不对了,呵呵,也就是说已经考虑到后面有0结果还是栽在0上了,呵呵
    如果判断后面有几个0就太繁了,现在想到新办法了~Function StrToNum(ByVal xStr As String) As Long
    xStr = "1" & StrReverse$(xStr) '^o^
    xStr = StrReverse$(Val(xStr))
    StrToNum = CLng(Left$(xStr, Len(xStr) - 1))
    End Function
      

  7.   

    StrReverse(val(StrReverse("aaaa123")))
      

  8.   

    方法1:
    Private Sub Command2_Click()
    str1 = "aaa1"
    str2 = "yhua10"
    str3 = "aaggga300"
    str4 = "abcdefg"
    MsgBox getnum(str1)
    MsgBox getnum(str2)
    MsgBox getnum(str3)
    MsgBox getnum(str4)
    End Sub
    Function getnum(ByVal s As String) As String
    For i = Len(s) To 1 Step -1
    If IsNumeric(Right(s, i)) Then
    getnum = Right(s, i)
    Exit Function
    End If
    Next
    getnum = "无数字"
    End Function
    ============================方法2(方法1特例):
    Private Sub Command1_Click()
    str1 = "aaa1"
    str2 = "aaa10"
    str3 = "aaa300"
    MsgBox Replace(str1, "a", "")
    MsgBox Replace(str2, "a", "")
    MsgBox Replace(str3, "a", "")
    End Sub
      

  9.   

    算法1:处理类似“asdbsf12233ndsdsb123324nddbd1234”的字符串,输出",12233,123324,1234",至于这种格式有什么用?呵呵!你自己用Split函数试试就知道了。Function NumberGetByString1(ByVal pString As String)
      Dim tOutText As String
      
      Dim tIndexOver As Long
      
      tIndexOver = Len(pString)
      
      Dim tIndex As Long '
      Dim tWord As String '
      Dim tAscii As Integer '
      Dim tIsNum As Boolean '数字检测
      Dim tIsNumOld As Boolean '数字检测旧值
      Dim tIsNumChange As Boolean '数字检测改变
      Dim tSumStr As String
      
      For tIndex = 1 To tIndexOver
        tWord = Mid(pString, tIndex, 1)
        tAscii = Asc(tWord)
        tIsNumOld = tIsNum
        tIsNum = tAscii >= 48 And tAscii <= 57
        tIsNumChange = tIsNum Xor tIsNumOld
        
        If tIsNumChange Then
          tOutText = tOutText & tSumStr
          tSumStr = ""
        End If
        
        If tIsNum Then
            tSumStr = tSumStr & tWord
          Else
            tSumStr = ","
        End If
          
      Next
      
      tOutText = tOutText & tSumStr
      
      NumberGetByString1 = tOutText
    End Function后面还有另一个算法2,稍后给你。
      

  10.   

    算法2:从信号角度采取过滤法实现,仅适合“aaaaa12313”类似的格式。注意:本方法针对的数字不能大于2的31次方,否则将溢出出错;同时,本算法不兼容负数。必须保证数字在0到&H7FFFFFFF范围内。本算法优点是特别迅速。Function NumberGetByString2(ByVal pString As String) As Long
      Dim tOutLong As Long
      
      If Not pString = "" Then
      
        Dim tBytes() As Byte
        Dim tBytes_Length As Byte
      
        tBytes() = pString
        tBytes_Length = UBound(tBytes())
        
        Dim tIndex As Long
        Dim tByteValue As Long
        Dim tByteIsNum As Boolean
        
        For tIndex = 0 To tBytes_Length Step 2
          tByteIsNum = tBytes(tIndex) >= 48 And tBytes(tIndex) <= 57
          tByteValue = tByteIsNum And (tBytes(tIndex) - 48)
          tOutLong = (tOutLong * 10) + tByteValue
        Next
      
      End If
      
      NumberGetByString2 = tOutLong
    End Function
      

  11.   

    最后再给你一个算法3:叫做“男的杀、女的X之字母符号抄家灭族算法”
    Function NumberGetByString3(ByVal pString As String) As String
      Dim tOutStr As String
      
      Dim tAscii As Integer
      
      For tAscii = 32 To 47
        pString = Replace(pString, Chr(tAscii), "")
      Next
      For tAscii = 58 To 127
        pString = Replace(pString, Chr(tAscii), "")
      Next
      
      NumberGetByString3 = pString
    End Function
      

  12.   

    呵。真高兴有这么多人回答呀。先谢谢各位了。本人采用了: BlueBeer的方法。很实用。再次感谢