不是明白你的要求,倒过来循环? dim i as long dim s as string for i=fg.rows-1 to 1 step -1 s=s & fg.textmatrix(i,1) next msgbox s
Private Sub Form_Load() Dim str As String, strNew As String str = "12354856102687937" str = StrReverse(str) Do While Len(str) > 0 If InStr(strNew, Left(str, 1)) = 0 Then strNew = strNew & Left(str, 1) End If str = Right(str, Len(str) - 1) Loop MsgBox strNew End Sub
Option ExplicitPrivate Sub Command1_Click() Dim newCol As New Collection
Dim i As Long
On Error Resume Next For i = MSHFlexGrid1.Rows - 1 To 1 Step -1 newCol.Add MSHFlexGrid1.TextMatrix(i, 0), "S" & MSHFlexGrid1.TextMatrix(i, 0) Next
For i = 1 To 10 MsgBox newCol.Item(i) Next End SubPrivate Sub Form_Load() MSHFlexGrid1.Cols = 1 MSHFlexGrid1.TextMatrix(1, 0) = "1" MSHFlexGrid1.AddItem "2" MSHFlexGrid1.AddItem "3" MSHFlexGrid1.AddItem "5" MSHFlexGrid1.AddItem "4" MSHFlexGrid1.AddItem "8" MSHFlexGrid1.AddItem "5" MSHFlexGrid1.AddItem "6" MSHFlexGrid1.AddItem "1" MSHFlexGrid1.AddItem "0" MSHFlexGrid1.AddItem "2" MSHFlexGrid1.AddItem "6" MSHFlexGrid1.AddItem "8" MSHFlexGrid1.AddItem "7" MSHFlexGrid1.AddItem "9" MSHFlexGrid1.AddItem "3" MSHFlexGrid1.AddItem "7" End Sub
dim i as long dim s as string,tmp as string dim b(9) as boolean
for i=fg.rows-1 to 1 step -1 tmp=fg.textmatrix(i,1) if not b(val(tmp)) then s=s & tmp b(val(tmp))=true end if next msgbox s
如果取出的数 在 0-9之间,则将对应的数组中的值更为 TRUE
在每次添加之前判断 数组A中是否全部已经为TRUE
也就是判断是否已经全部取值完毕
dim i as long
dim s as string
for i=fg.rows-1 to 1 step -1
s=s & fg.textmatrix(i,1)
next
msgbox s
Dim str As String, strNew As String
str = "12354856102687937"
str = StrReverse(str)
Do While Len(str) > 0
If InStr(strNew, Left(str, 1)) = 0 Then
strNew = strNew & Left(str, 1)
End If
str = Right(str, Len(str) - 1)
Loop
MsgBox strNew
End Sub
Option ExplicitPrivate Sub Command1_Click()
Dim newCol As New Collection
Dim i As Long
On Error Resume Next For i = MSHFlexGrid1.Rows - 1 To 1 Step -1
newCol.Add MSHFlexGrid1.TextMatrix(i, 0), "S" & MSHFlexGrid1.TextMatrix(i, 0)
Next
For i = 1 To 10
MsgBox newCol.Item(i)
Next
End SubPrivate Sub Form_Load()
MSHFlexGrid1.Cols = 1
MSHFlexGrid1.TextMatrix(1, 0) = "1"
MSHFlexGrid1.AddItem "2"
MSHFlexGrid1.AddItem "3"
MSHFlexGrid1.AddItem "5"
MSHFlexGrid1.AddItem "4"
MSHFlexGrid1.AddItem "8"
MSHFlexGrid1.AddItem "5"
MSHFlexGrid1.AddItem "6"
MSHFlexGrid1.AddItem "1"
MSHFlexGrid1.AddItem "0"
MSHFlexGrid1.AddItem "2"
MSHFlexGrid1.AddItem "6"
MSHFlexGrid1.AddItem "8"
MSHFlexGrid1.AddItem "7"
MSHFlexGrid1.AddItem "9"
MSHFlexGrid1.AddItem "3"
MSHFlexGrid1.AddItem "7"
End Sub
dim s as string,tmp as string
dim b(9) as boolean
for i=fg.rows-1 to 1 step -1
tmp=fg.textmatrix(i,1)
if not b(val(tmp)) then
s=s & tmp
b(val(tmp))=true
end if
next
msgbox s