扫雷游戏的实现
解决方案 »
- vb組合框問題,紀錄定位,高手來幫幫我
- 各位大侠,请教一个问题,怎么再sql server的表里添加一个自动增长的整型字段
- vb调用带输出参数的存储过程?(紧急)
- 打包新问题,在线等待,望大家帮忙
- 请教用API方法或其他方法(非循环查找方法)确定文本框光标所在行数。
- 这么去掉activebar控件中toolbar对象的标题栏目
- 在多用户下怎样通过控制对各种控件(如command)的属性,从而达到控制用户的权限存取。。。?
- 在MSDN中找不到的错误号,谁知道,,,急 ¥¥¥¥¥¥¥¥¥
- 在每次单击command1控件后怎么使之发音,看看我这样为什么只能发音一次!
- 一个VB网站的兴起!COOL!
- CommonDialog使用上的一个问题~~~大家帮忙,在线等,马上给分
- 请问如何实现鼠标的移动和模拟按键?
然后程序初始时随机设置数组元素的有雷属性.鼠标点击后设置数组元素当前状态属性,再判断周遭8个区域内的数组元素属性,然后计算出应该显示的雷数......
If CBool(SheepCount(priFold())) Then '如果羊圈里还有羊的话
Text2.Text = SheepNabByFold(priFold()) '羊圈存栏数量
Text1.Text = SheepCount(priFold()) '被抓住的小羊羔编号
For tIndex = 0 To SheepCount(priFold()) - 1 '显示羊圈里的小羊。
Text1.Text = Text1.Text & " " & priFold(tIndex)
Next
Else
Text1.Text = "没有羊了!你还乱抓什么?"
End If
End SubPrivate Sub Form_Load()
Randomize Timer
ReDim priFold(100)
For tIndex = 0 To 100
priFold(tIndex) = tIndex
Next
End SubFunction SheepCount(ByRef pFold() As Long) As Long
Dim tOutCount As Long
Dim tSheepIndex_Start As Long
Dim tSheepIndex_End As Long
Dim tSheepIndex_Rnd As Long
Err.Clear
On Error Resume Next
tSheepIndex_End = UBound(pFold): tSheepIndex_Start = LBound(pFold)
If Not CBool(Err.Number) Then
tOutCount = Abs(tSheepIndex_End - tSheepIndex_Start) + 1
End If
SheepCount = tOutCount
End FunctionFunction SheepNabByFold(ByRef pFold() As Long) As Long
Dim tOutSheep As Long
Dim tSheepIndex As Long
Dim tSheepCount As Long
Dim tSheepIndex_Start As Long
Dim tSheepIndex_End As Long
Dim tSheepIndex_Rnd As Long
Dim tFoldSpace() As Long
tSheepIndex_End = UBound(pFold()): tSheepIndex_Start = LBound(pFold())
tSheepCount = SheepCount(pFold()) '计算当前数组编号。
tSheepIndex_Rnd = Int(Rnd * tSheepCount) + tSheepIndex_Start
'取合法随机编号。 SheepSwap pFold(tSheepIndex_End), pFold(tSheepIndex_Rnd)
'将末尾的元素与第随机个元素交换(注意,随机元素必须在目前存在的编号范围内)。
tOutSheep = pFold(tSheepIndex_End)
If tSheepCount < 2 Then
pFold() = tFoldSpace()
Else
ReDim Preserve pFold(tSheepIndex_End - 1) '缩小数组,保留数值。
End If
SheepNabByFold = tOutSheep
End FunctionSub SheepSwap(ByRef pSheepA As Long, ByRef pSheepB As Long)
Dim tSheep As Long
tSheep = pSheepA: pSheepA = pSheepB: pSheepB = tSheep
End Sub
For YIndex=Y-1 To Y+1
MCount=MCount+(有雷判断(X,Y) And 1)
Next
Nexy