4 回答
TA贡献1860条经验 获得超9个赞
'这是一个函数,s是数字字符串,ary是数组,返回一个新的数组
'这里假设B是Integer型,返回的也是Integer,你根据自己情况改一下(里面的temp也要改),
Function GetBData(s As String, ary() As Integer) As Integer()
Dim lLen As Long, i As Long
Dim temp() As Integer
lLen = Len(s) \ 2
ReDim temp(lLen - 1)
For i = 0 To lLen - 1
temp(i) = ary(CInt(Mid(s, i * 2 + 1, 2)) - 1)
Next
GetBData = temp
End Function
调用方法:
Dim r() As Integer
r = GetBData(L, B)'这里的r就是得到的新数组
TA贡献1784条经验 获得超9个赞
你是想问每两个数提取出来对应的字符吗
Dim L As String, I As Integer
L = "0103050811"
For I = 2 To Len(L) Step 2
A = Right(Left(L, I), 2)
'A = Chr(Right(Left(L, I), 2))'如果想转换成字符就用这句
Next
TA贡献1963条经验 获得超6个赞
'假设B数组已经定义并赋值
dim NewArray()
Private Sub Command1_Click()
L="0103050811"
redim NewArray(len(L)/2)
n=0
For i = 1 To Len(L) Step 2
j = Val(Mid(L, i, 2))
If j <= UBound(b) Then newarray(n)=b(j)
n=n+1
Next
End Sub
TA贡献1789条经验 获得超10个赞
Private Sub Command1_Click()
l = "0103050811"
For i = 1 To Len(l) Step 2
j = Val(Mid(l, i, 2))
If j <= UBound(b) Then Print b(j)
Next
End Sub
- 4 回答
- 0 关注
- 140 浏览
添加回答
举报