7,763
社区成员
发帖
与我相关
我的任务
分享
Private Function NumComp(pStr As String, bol() As Boolean) As String
Dim a
Dim b() As Boolean
Dim N As Long, i As Long
b = bol
a = Split(pStr, Chr(32))
For i = 0 To UBound(a)
If b(a(i)) Then
N = N + 1
b(i) = False
a(i) = ""
End If
Next
If N = 4 Then
NumComp = pStr & " '" & Trim(Join(a))
End If
End Function
Private Sub Command1_Click()
Const N = 99 '假设你最大数是99
Dim s As String
Dim s1(9) As String
Dim arr
Dim ii As Long
Dim bol(N) As Boolean
s1(0) = "1 2 3 4 5"
s1(1) = "2 3 4 5 6"
s1(2) = "3 4 5 6 7"
s1(3) = "4 5 6 7 8"
s1(4) = "5 6 7 8 9"
s1(5) = "6 7 8 9 10"
s1(6) = "7 8 9 10 11"
s1(7) = "8 9 10 11 12"
s1(8) = "9 10 11 12 13"
s1(9) = "10 11 12 13 14"
s = "3 8 9 4 10 7"
arr = Split(s, Chr(32))
For ii = 0 To UBound(arr)
bol(arr(ii)) = True
Next
For ii = 0 To 9
arr = NumComp(s1(ii), bol)
If Len(arr) > 0 Then MsgBox arr
Next
End Sub
Private Sub Command1_Click()
Dim i As Integer
Dim j As Integer
Dim a(9) As String
Dim b As String
Dim intCount As Integer
a(0) = "1 2 3 4 5"
a(1) = "2 3 4 5 6"
a(2) = "3 4 5 6 7"
a(3) = "4 5 6 7 8"
a(4) = "5 6 7 8 9"
a(5) = "6 7 8 9 10"
a(6) = "7 8 9 10 11"
a(7) = "8 9 10 11 12"
a(8) = "9 10 11 12 13"
a(9) = "10 11 12 13 14"
b = "13 6 4 5 10 10"
b = " " & b & " "
For i = 0 To UBound(a)
intCount = 0
For j = 0 To UBound(Split(a(i), " "))
If InStr(b, " " & Split(a(i), " ")(j) & " ") > 0 Then
intCount = intCount + 1
Else
strtemp = Split(a(i), " ")(j)
End If
Next j
If intCount = 4 Then
Debug.Print a(i) & ", " & strtemp
End If
Next i
End Sub
private function NumComp(pStr as string,bol() as boolean) as string
dim a
dim b() as boolean
dim n as long,i as long
b=bol
a=split(pStr,chr(32))
for i=0 to ubound(a)
if b(a(i))then
n=n+1
b=false
a(i)=""
end if
next
if n=4 then
NumComp=trim(join(a))
else
NumComp=0
end if
end function
Dim s as string
dim s1(9) string
dim arr
dim ii as string
dim bolIs(36) as boolean '
s1(0) = "1 2 3 4 5"
s1(1) = "2 3 4 5 6"
s1(2) = "3 4 5 6 7"
s1(3) = "4 5 6 7 8"
s1(4) = "5 6 7 8 9"
s1(5) = "6 7 8 9 10"
s1(6) = "7 8 9 10 11"
s1(7) = "8 9 10 11 12"
s1(8) = "9 10 11 12 13"
s1(9) = "10 11 12 13 14"
s = "3 8 9 4 10 7"
arr=split(s,chr(32))
for ii=0 to ubound(arr)
bolIs(arr(ii))=true
next
for ii=0 to 9
msgbox NumComp(s1(ii),bolIs)
next
dim i as integer
dim j as integer
dim a(9) as string
dim b as string
dim intCount as integer
a(0)="1 2 3 4 5"
a(1)="2 3 4 5 6"
a(2)="3 4 5 6 7"
a(3)="4 5 6 7 8"
a(4)="5 6 7 8 9"
a(5)="6 7 8 9 10"
a(6)="7 8 9 10 11"
a(7)="8 9 10 11 12"
a(8)="9 10 11 12 13"
a(9)="10 11 12 13 14"
b="3 8 9 4 10 7"
for i=0 to 9
intCount=0
for j=0 to ubound(split(a(i)," "))
if instr(b,split(a(i)," ")(j))>0 then
intcount=intcount+1
else
strtemp=split(a(i)," ")(j)
end if
next j
if intcount=4 then
msgbox a(i) & ", " & strtemp
end if
next i