求VB编写中国象棋的源代码。急求。必有重谢 10
1个回答
2016-07-08
展开全部
贴保存棋局和读取棋局部分的,你先看看:
Rem 读取棋局
Private Sub mnuRead_Click()
Dim s As String, i As Integer, t
If Dir(App.Path & "\cchess.che") = "" Then MsgBox "没有棋局文件可以读入!请先保存棋局!", , "中国象棋": Exit Sub
Open App.Path & "\cchess.che" For Input As #1
Input #1, s
Close #1
s = Replace(s, vbCrLf, "")
s = Trim(s)
t = Split(s, " ")
If UBound(t) <> 89 Then MsgBox "棋局文件已遭到破坏!请重新保存棋局!", , "中国象棋": Exit Sub
For i = 0 To 89
a(i) = Val(t(i))
Next
MsgBox "棋局文件已成功读入!", , "中国象棋"
End Sub
Rem 保存棋局
Private Sub mnuSave_Click()
Dim s As String, i As Integer
s = ""
For i = 0 To 89
s = s & " " & a(i)
Next
s = Trim(s)
Open App.Path & "\cchess.che" For Output As #1
Print #1, s;
Close #1
MsgBox "当前棋局已成功保存!", , "中国象棋"
End Sub
Rem 读取棋局
Private Sub mnuRead_Click()
Dim s As String, i As Integer, t
If Dir(App.Path & "\cchess.che") = "" Then MsgBox "没有棋局文件可以读入!请先保存棋局!", , "中国象棋": Exit Sub
Open App.Path & "\cchess.che" For Input As #1
Input #1, s
Close #1
s = Replace(s, vbCrLf, "")
s = Trim(s)
t = Split(s, " ")
If UBound(t) <> 89 Then MsgBox "棋局文件已遭到破坏!请重新保存棋局!", , "中国象棋": Exit Sub
For i = 0 To 89
a(i) = Val(t(i))
Next
MsgBox "棋局文件已成功读入!", , "中国象棋"
End Sub
Rem 保存棋局
Private Sub mnuSave_Click()
Dim s As String, i As Integer
s = ""
For i = 0 To 89
s = s & " " & a(i)
Next
s = Trim(s)
Open App.Path & "\cchess.che" For Output As #1
Print #1, s;
Close #1
MsgBox "当前棋局已成功保存!", , "中国象棋"
End Sub
追问
是编写整个源代码。包括棋子与棋盘的联系,各棋子的走法代码。
意法半导体(中国)投资有限公司
2023-06-12 广告
2023-06-12 广告
单片机汇编程序是用汇编语言编写的程序,用于控制单片机的操作。汇编语言是一种比较接近计算机硬件语言的低级语言,相对于高级语言来说更容易理解和实现。下面是单片机汇编程序的基本步骤:1. 将代码和数据汇编到规定的段中。2. 在存储器中用未初始化的...
点击进入详情页
本回答由意法半导体(中国)投资有限公司提供
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询