½Ð°Ý¦p¦ó¥ÎARRAY°µ¸ê®Æ¤ñ¹ï¡H
- ©«¤l
- 83
- ¥DÃD
- 17
- ºëµØ
- 0
- ¿n¤À
- 105
- ÂI¦W
- 0
- §@·~¨t²Î
- XP
- ³nÅ骩¥»
- XP
- ¾\ŪÅv
- 20
- µù¥U®É¶¡
- 2010-12-28
- ³Ì«áµn¿ý
- 2018-8-8
|
½Ð°Ý¦p¦ó¥ÎARRAY°µ¸ê®Æ¤ñ¹ï¡H
¬Ý¤F¤@¨ÇVBAªº±Ð¾Ç¡A¬Ý±o¥bÀ´¤£À´¡CÁÙ¬O¦Û¤v°Ê¤â¼g¤@¨ÇVBAªº¤pµ{¦¡¡A©â¾Ç±o¤ñ¸û§Ö¡C
³Ìªñ¹Á¸Õ¥ÎVBA¼gBINGO¹CÀ¸¡A³y¼Æ¦r¥dªº³¡¥÷©M©â¸¹½Xªº³¡¥÷³£¯à¦¨¥\¡A¥i¬O¥ÎVBA¹ï¸¹½Xªº³¡¥÷§Ú«o¤£¤F¸Ñ¡C
¥Ñ©óBINGO¹CÀ¸¥un¬O¡Gª½¡B¾î¡B¹ï¨¤½u¦¨¤@½u«K¥i¥H³Ó¥X¡C¥H5X5ªº¼Æ¦r¥d¬°¨Ò¡A¬O§_§Ú»Ýn¼g¤U
5¾î¡B5ª½¡B2¹ï¨¤¡A¦@12Ó²Õ¦XªºIF CONDITION¤~¯à°µ¤ñ¹ï¡H
´¿°Ý¹L¦P¨Æ¡A¥L«Øij§Ú¥i¥H¥ÎARRAYªº¤èªk°µ¡A¥]¬A©â¸¹½X©M³y¼Æ¦r¥d¤]¥i¥H¡C
§Ú¤j·§¤]¸Õ¹LARRAY¡A¥ý§âÀH¾÷¼Æ¦r©ñ¦bARRAY¤¤¡A¦A¶¶§Ç©â¥X¡A¦ý§ÚµLªkÁקK«½Æ¼Æ¦r¡C
©Ò¥H§Ú·Q½Ð±Ð¤j®a¡A¤p§ÌªºDRAW©MPAPERªºµ{§Ç¥i¥H¥ÎARRAY§ï¼g¶Ü¡H
¥t¥~¡A¦p¦ó¦b©â¤@Ó·sªº¸¹½X®É¤ñ¹ï¼Æ¦r¥d¡A¬Ý¬Ý¬O§_¤¤¼ú¡AÁÂÁ¤j®a¡C |
-
-
bango.rar
(14.37 KB)
|
|
|
|
|
|
- ©«¤l
- 5923
- ¥DÃD
- 13
- ºëµØ
- 1
- ¿n¤À
- 5986
- ÂI¦W
- 0
- §@·~¨t²Î
- win10
- ³nÅ骩¥»
- Office 2010
- ¾\ŪÅv
- 150
- ©Ê§O
- ¨k
- ¨Ó¦Û
- ¥xÆW°ò¶©
- µù¥U®É¶¡
- 2010-5-1
- ³Ì«áµn¿ý
- 2022-1-23
|
¥»©«³Ì«á¥Ñ GBKEE ©ó 2011-12-16 17:53 ½s¿è
¦^´_ 1# ¤p«L«È - Option Explicit
- Public Rng As Range, Rng1 As Range, Rng2 As Range
- Sub Restart()
- Sheets(1).Cells.Clear
- End Sub
- Sub Draw()
- Dim B As Integer, C As Integer, d As Integer
- With Sheet1
- L:
- B = Int(100 * Rnd() + 1)
- C = Application.CountIf(.Range("A:A"), B) '¤ñ¹ï¬O§_«´_
- If C = 1 Then GoTo L: '«°µ¶Ã¼Æ
- d = Application.CountA(.Range("A:A")) + 5
- .Cells(d, 1) = B
- .Cells(d, 1).Select
- Bingo (B)
- End With
- End Sub
- Sub Paper()
- Dim E As Range, B As Integer, i As Integer, ii As Integer
- Set Rng = [Sheet1!I1:M5] '³]©w¼Æ¦r°Ï°ì
- For Each E In Rng
- L:
- B = Int(100 * Rnd() + 1)
- C = Application.CountIf(Rng, B) '¤ñ¹ï¬O§_«´_
- If C = 1 Then GoTo L:
- E = B
- Next
- For i = 1 To 5 '³]©w¹ï¨¤½u¥Ñ¥ª¦Ü¥k°Ï°ì
- If i = 1 Then
- Set Rng1 = Rng.Cells(i, i)
- Else
- Set Rng1 = Union(Rng1, Rng.Cells(i, i))
- End If
- Next
- ii = 5
- For i = 1 To 5 '³]©w¹ï¨¤½u¥Ñ¥k¦Ü¥ª°Ï°ì
- If i = 1 Then
- Set Rng2 = Rng.Cells(i, ii)
- Else
- Set Rng2 = Union(Rng1, Rng.Cells(i, ii))
- End If
- ii = ii - 1
- Next
- End Sub
- Sub Bingo(No As Integer)
- Dim f As Range, d As Integer, C As Range, i As Integer, ii As Integer
- Set f = Rng.Find(No, LookIn:=xlValues, LOOKAT:=xlWhole) '´M§ä¼Æ¦r
- If f Is Nothing Then Exit Sub
- If Not f Is Nothing Then
- f.Font.ColorIndex = 3 '§ä¨ì¼Æ¦rµ¹¦rÅéÃC¦â
- f.Font.FontStyle = "²ÊÅé" '§ä¨ì¼Æ¦rµ¹¦r«¬¼Ë¦¡
- End If
- For i = 1 To Rng.Columns.Count
- d = 0
- For Each C In Rng.Columns(i).Cells
- If C.Font.ColorIndex = 3 Then d = d + 1
- Next
- If d = 5 Then Rng.Columns(i).Select: GoTo ok
- Next
- For i = 1 To Rng.Rows.Count 'Àˬd¾î¦C
- d = 0
- For Each C In Rng.Rows(i).Cells
- If C.Font.ColorIndex = 3 Then d = d + 1
- Next
- If d = 5 Then Rng.Rows(i).Select: GoTo ok
- Next
- d = 0
- For Each C In Rng1 'Àˬd¹ï¨¤½u
- If C.Font.ColorIndex = 3 Then d = d + 1
- Next
- If d = 5 Then Rng1.Select: GoTo ok
- d = 0
- For Each C In Rng2 'Àˬd¹ï¨¤½u
- If C.Font.ColorIndex = 3 Then d = d + 1
- Next
- If d = 5 Then Rng2.Select: GoTo ok
- Exit Sub
- ok:
- MsgBox "Bingo"
- End Sub
½Æ»s¥N½X |
|
|
|
|
|
|
- ©«¤l
- 4901
- ¥DÃD
- 44
- ºëµØ
- 24
- ¿n¤À
- 4916
- ÂI¦W
- 242
- §@·~¨t²Î
- Windows 7
- ³nÅ骩¥»
- Office 20xx
- ¾\ŪÅv
- 150
- ©Ê§O
- ¨k
- ¨Ó¦Û
- ¥x¥_
- µù¥U®É¶¡
- 2010-4-30
- ³Ì«áµn¿ý
- 2024-11-8
|
¦^´_ 1# ¤p«L«È - Public k%
- Sub Draw()
- If Application.CountA([A:A]) >= k ^ 2 Then Exit Sub
- n = Int((k ^ 2) * Rnd + 1)
- Do Until IsError(Application.Match(n, [A:A], 0))
- n = Int((k ^ 2) * Rnd + 1)
- Loop
- r = Application.CountA([A:A]) + 1
- [A5].Offset(r) = n
- Set a = Range("I1").CurrentRegion.Find(n, lookat:=xlWhole)
- a.Interior.ColorIndex = 3
- Set b = a.EntireColumn
- Set c = a.EntireRow
- ar = Array(b, c)
- For i = 0 To 1
- yn = True
- For Each x In Intersect(ar(i), Range("I1").CurrentRegion)
- If x.Interior.ColorIndex <> 3 Then yn = False: Exit For
- Next
- If yn = True Then MsgBox "Bango!!!": Exit Sub
- Next
- Set b = [I1]
- Set c = [I1].Offset(, k - 1)
- ar = Array(b, c)
- For i = 0 To 1
- yn = True: x = IIf(i = 0, 1, -1)
- For j = 0 To k - 1
- If ar(i).Offset(j, j * x).Interior.ColorIndex <> 3 Then yn = False: Exit For
- Next
- If yn = True Then MsgBox "Bango!!!": Exit Sub
- Next
- End Sub
- Sub Restart()
- Sheets(1).Cells.Clear
- Sheets(2).Cells.Clear
- Sheets(3).Cells.Clear
- End Sub
- Sub Paper()
- k = InputBox("¿é¤J°}¦Cºû¼Æ", , 5)
- ReDim ar(k, k)
- ReDim ay(k, k)
- For i = 0 To k - 1
- For j = 0 To k - 1
- ar(i, j) = Rnd
- Next
- Next
- [I1].Resize(k, k) = ar
- For i = 0 To k - 1
- For j = 0 To k - 1
- ay(i, j) = Application.Rank(ar(i, j), [I1].Resize(k, k))
- Next
- Next
- [I1].Resize(k, k) = ay
- End Sub
½Æ»s¥N½X |
|
¾Ç®üµL²P_¤£®¢¤U°Ý
|
|
|
|
|