求助,字符串中提取数字问题
哪位大侠,能帮我写个函数,从字符串中分别提取数字,谢谢!第12大排第8小排第10个集装箱
Private Sub Command1_Click() Text2.Text = "" Dim STT As String, STT1 As String, B As Integer, C As Integer, AA() As Byte, I As Integer STT = Text1.Text '得到需要检测的字符串 B = 0: C = Len(STT) 'C变量是字符串长度 ReDim AA(1 To C) For I = 1 To C AA(I) = 200 '初始化AA数组,赋值为200 Next I For I = 1 To C STT1 = Mid(STT, I, 1) 'STT1变量得到各字符 B = B + 1 If IsNumeric(STT1) = True Then '判断字符是不是数字 AA(B) = Val(STT1) '是数字,修改AA数组的值 End If Next I Dim D As Integer, BB() As Byte For I = 1 To C - 1 If AA(I) < 100 And AA(I + 1) < 100 Then '判断AA数组的值是否小于100,并且是否是连续的 AA(I) = AA(I) * 10 + AA(I + 1) '如果连续修改第一个数字为第一个数字*10+第二个数字 AA(I + 1) = 200 '第二个数字修改为200 End If Next I For I = 1 To C If AA(I) < 100 Then '判断AA数组的值是否小于100 D = D + 1 '得到小于100数组的数 End If Next I ReDim BB(1 To D) D = 0 For I = 1 To C If AA(I) < 100 Then '判断AA数组的值是否小于100 D = D + 1 BB(D) = AA(I) '小于100赋值给BB数组 End If Next I For I = 1 To D Text2.Text = Text2.Text & BB(I) & Space(5) '显示检测出来的数字。 Next I End Sub