现有一个程序要得到机器的返回值,其返回值为一个固定格式的字符串
首位为标示返回值种类的符号,例“=”、“#”等
中间为返回内容,为数字或数字及字符的组合,例“123.5”、“01DATA”
末位为回车符(0DH)请问:
如何取得返回值中字符数字组合中的数字部分,例:“=+0012.N/”(末位的/为回车符),要求分别取得正号和数字0012.明天回来结贴,谢谢。

解决方案 »

  1.   

    Private Sub Command3_Click()
    Dim a As String
    Dim b As Stringa ="=+0012.N/"
    b = Mid(a, 2, Len(a) - 1)
    MsgBox b'b就是你要的数据End Sub
      

  2.   

    做个界面,两个textbox,一个command,名字不要改Private Function CheckChar(ByVal strChar As String) As Boolean
    ''48~57 (数字0~9 )
    ''65~90 (大写字母A~Z)
    ''97~122 (小写字母 a~z)    Dim intChar As Integer
        intChar = Asc(strChar)
        Select Case intChar
            Case 48 To 57, 65 To 90, 97 To 122
                CheckChar = True
                Exit Function
            Case Else
                CheckChar = False
        End Select
    End FunctionPrivate Sub Command1_Click()
        Dim i As Integer
        Dim strAll As String
        Dim strGet As String
        
        strAll = Text1.Text
        
        For i = 1 To Len(strAll)
            If CheckChar(Mid(strAll, i, 1)) Then
                strGet = strGet & Mid(strAll, i, 1)
            End If
        Next
        
        Text2.Text = strGet
    End Sub========================如果你还要增加其他字符
    只要修改CheckChar即可
      

  3.   

    Private Sub Command1_Click()
        Dim strValue As String
        strValue = "=+0012.N/"
        Dim i As Integer
        Dim s As String
        Dim strEnd As String
        For i = 1 To Len(strValue)
            s = Mid(strValue, i, 1)
            If IsNumeric(s) = True Or s = "+" Or s = "-" Then
                strEnd = strEnd + s
            End If
        Next
        
        MsgBox strEnd
    End Sub
      

  4.   

    Text1.Text = "=0012." & vbCrLf
    Dim temp As String
    temp = Mid(Text1.Text, 1, 1)
    Select Case tempCase "="
    '数字
        MsgBox Val(Mid(Text1.Text, 2, Len(Text1.Text) - 1))
            
    Case "#"
    '字符串
         MsgBox Mid(Text1.Text, 2, Len(Text1.Text) - 1)
    End Select