Public i As Integer
Public m As Integer
Public n As Integer
Public B As Integer
Public S As Integer
Dim buyArray(99) As Single
Dim sellArray(99) As Single
Private Sub CommandButton1_Click()
B = 1
i = i + 1
Sheets("sheet1").Cells(i, 1) = "¶R"
Sheets("sheet1").Cells(i, 2) = Int((10 * Rnd) + 1)
m = m + 1
buyArray(m) = Sheets("sheet1").Cells(i, 2)
If B = S Then
If m > n Then
Sheets("sheet1").Cells(i, 3) = sellArray(n) - buyArray(n)
S = 0
Else
Sheets("sheet1").Cells(i, 3) = sellArray(m) - buyArray(m)
B = 0
End If
End If
End Sub
Private Sub CommandButton2_Click()
S = 1
i = i + 1
Sheets("sheet1").Cells(i, 1) = "½æ"
Sheets("sheet1").Cells(i, 2) = Int((10 * Rnd) + 1)
n = n + 1
sellArray(n) = Sheets("sheet1").Cells(i, 2)
If S = B Then
If n > m Then
Sheets("sheet1").Cells(i, 3) = sellArray(m) - buyArray(m)
B = 0
Else
Sheets("sheet1").Cells(i, 3) = sellArray(n) - buyArray(n)
S = 0
End If
End If
End Sub |