LoginSignup
0

More than 5 years have passed since last update.

【VBS】ArrayListの使い方を教えて下さい。

Last updated at Posted at 2016-03-24

ArrayListを繰り返していますが、関数にする方法を教えて下さい。
よろしくお願いします。
```vbs:filename.vbs
'文字,X座標,Y座標
'「入力」
'文字A,3.0,0.0
'文字B,3.0,-15.0
'文字C,12.0,0.0
' ↓↓↓
'「出力」
'文字A,文字C
'文字B
'------------------------------------------------------------------
const MyFS=","
const MyOFS=","
dim gyoin(50)
ngyo=3
gyoin(0)="文字A" & MyFS & "3.0" & myFs & "0.0"
gyoin(1)="文字B" & MyFS & "3.0" & myFs & "-15.0"
gyoin(2)="文字C" & MyFS & "12.0" & myFs & "0.0"
'------------------------------------------------------------------
const MojiTakasa=1.0
dim gyoc(50)
dim gyox(50)
dim gyoy(50)
dim gyocyx(50,50)
Dim myArrayListX
Set myArrayListX = CreateObject("System.Collections.ArrayList")
Dim myArrayListY
Set myArrayListY = CreateObject("System.Collections.ArrayList")
'------------------------------------------------------------------
for i=0 to ngyo-1
cxy=split(gyoin(i),",")
gyoc(i)=cxy(0)
gyox(i)=int(cxy(1)/MojiTakasa)
gyoy(i)=int(cxy(2)/MojiTakasa)
myArrayListX.add gyox(i)
myArrayListY.add gyoy(i)
next
'-------------------------------------------------------------------
myArrayListX.Sort
For i = myArrayListX.Count - 1 To 1 Step -1
If myArrayListX(i-1) = myArrayListX(i) Then
myArrayListX.RemoveAt(i)
End
If
Next
'
myArrayListY.Sort
myArrayListY.Reverse
For i = myArrayListY.Count - 1 To 1 Step -1
If myArrayListY(i-1) = myArrayListY(i) Then

myArrayListY.RemoveAt(i)
End If
Next
'-------------------------------------------------------------------
For i = 0 To ngyo-1
For j = 0 To myArrayListY.Count-1
For k = 0 To myArrayListX.Count-1
if gyoy(i)=myArrayListY(j) and _
gyox(i)=myArrayListX(k) then
if gyocyx(j,k) = "" then
gyocyx(j,k) = gyoc(i)
else
gyocyx(j,k) = gyocyx(j,k) & "と" & gyoc(i)
end if
end
if
Next
Next
Next
'-------------------------------------------------------------------
otMoji=""
For j = 0 To myArrayListY.Count-1
For k = 0 To myArrayListX.Count-1
if k = 0 then
otMoji=otMoji & gyocyx(j,k)
else
otMoji=otMoji & MyOFS & gyocyx(j,k)
end if
Next
otMoji=otMoji & vbCrLf
Next
'-------------------------------------------------------------------
msgbox otMoji
```

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0