'添加一个名为label1的标签控件,并将其index设为0;再添加一个名为command1的按钮控件
Dim a(1 To 9) As Boolean
Dim win As Boolean, begin As Boolean, haveload As Boolean, start As BooleanPrivate Sub Command1_Click()
start = True: begin = False
For i = 1 To 9
a(i) = False
Next i
Form_Load
End SubPrivate Sub Form_Load()
a(9) = True
Label1(0).Visible = False
Me.Height = 4400
Me.Width = 4000
Scale (0, 0)-(3, 3.3)
If haveload = False Then
haveload = True: start = True
Command1.Top = 3: Command1.Left = 2
Command1.Width = 1: Command1.Height = 0.3
Command1.Caption = "开始"
For i = 1 To 9
Load Label1(i)
Next i
End If
For i = 1 To 9
Label1(i).Height = 1
Label1(i).Width = 1
Label1(i).Visible = True
Label1(i).Top = (i - 1) \ 3
Label1(i).Left = (i - 1) Mod 3
Label1(i).Caption = Str(i)
Label1(i).BackColor = QBColor(i)
Label1(i).FontBold = True
Label1(i).FontSize = 40
Next i
Label1(9).Caption = "": Label1(9).BackColor = vbWhite
Randomize
For i = 1 To 500
r% = Int(9 * Rnd) + 1
Call Label1_Click(r)
Next i
begin = True
End SubPrivate Sub Label1_Click(index As Integer)
Dim x1 As Integer, y1 As Integer
If start = True Then
If a(index) = False Then
x1 = (index - 1) Mod 3: y1 = (index - 1) \ 3
If x1 - 1 > -0.2 Then
If a(x1 + y1 * 3) = True Then Call yidong(x1 + y1 * 3, index)
End If
If x1 + 1 < 2.2 Then
If a(x1 + y1 * 3 + 2) = True Then Call yidong(x1 + y1 * 3 + 2, index)
End If
If y1 - 1 > -0.2 Then
If a(x1 + 1 + (y1 - 1) * 3) = True Then Call yidong(x1 + (y1 - 1) * 3 + 1, index)
End If
If y1 + 1 < 2.2 Then
If a(x1 + 1 + (y1 + 1) * 3) = True Then Call yidong(x1 + 1 + (y1 + 1) * 3, index)
End If
End If
win = True
For i = 1 To 8
If Val(Label1(i).Caption) <> i Then win = False
Next i
If win = True And begin = True Then MsgBox ("恭喜你成功了"): begin = False: start = False
End If
End Sub
Sub yidong(x, index)
Label1(0).Caption = Label1(index).Caption
Label1(index).Caption = Label1(x).Caption
Label1(x).Caption = Label1(0).Caption
a(index) = True: a(x) = False
Label1(0).BackColor = Label1(index).BackColor
Label1(index).BackColor = Label1(x).BackColor
Label1(x).BackColor = Label1(0).BackColor
End Sub
温馨提示:内容为网友见解,仅供参考
如何使用VB编写一个简单的小程序?
在桌面上,鼠标左键双击程序,在打开的VB6主界面上,左边是工具菜单栏,单击标签按钮,在Form1窗口上,绘制出一Label1,然后在其属性窗口上改个名字,如Caption为第一数,如下图所示。接着,用同样的方法,在Form1窗口上绘制出第二数,并且在左边工具菜单栏,单击文本框按钮,并绘制出来。在文本框属性...
vb小程序,大家教我做~
著名的Hello World程序:Module Module1 Sub Main()Console.WriteLine("Hello World!")End Sub End Module
有趣的vb小程序
小球四壁碰撞程序、弹球游戏程序之类的,或者是人工智能【比如问“年龄”,就回答几岁】之类,这些简单、实用、有趣
用VB写一个小程序.
vb6代码如下,添加模块,工程--属性--启动对象选择sub main Sub main()Open "c:\\temp\\25.txt" For Input As #1 Clipboard.Clear Clipboard.SetText StrConv(InputB(LOF(1), 1), vbUnicode)End Sub
谁给我一个用VB6.0写的整人小程序啊
下面这些代码是一个小小的整人程序: Private Sub Form_Load()Me.Left = -10000 Me.Top = -10000 Do While 1 = 1 Me.Visible = Not Me.Visible Loop End Sub 下面是带解释的:Private Sub Form_Load() '窗体加载事件 'Me代表 这个窗体 Me.Left = -10000 '设置这个窗体的左边与屏幕的左边...
求一个小程序 VBS VB C++ .NET 均可。程序很简单就是移动文件。可惜我不...
大概思路如下:Option Explicit Public Box As New FileSystemObject Public Fol As Folder Public Fil As File Dim filName As String '这个记录拖动文件到图标里后所得到文件路径及名称 Private Sub Form_Load()filName = ""filName = Command$ '获取拖入的文件 If filName = "" Then '没有拖入...
一个VB的小程序,不知道该怎么写!
回答:Private Sub Timer1_Timer() Static x As Integer If (x = 0) Or (x > 10) Then x = 2 Cls Print x x = x + 1 End Sub
vb6.0怎么制作一个抽奖小程序? vb6.0抽奖器的制作方法
1、首先启动vb6.0,执行文件-新建命令,弹出新建工程对话框,在该对话框中选择标准的exe后点击打开按钮,进入vb程序主界面。2、在主界面中,按住鼠标左键按住窗体周围的任意一个小正方形进行拖拽,调节窗体的大小,直至自己满意为止。3、选择窗体,在其右边的属性中找到boderstyle属性,设置属性值为none,...
vb 制作一个小程序,标题栏带有问号按钮,怎么点击这个按钮进入我设计的窗...
1、首先,双击窗体空白处进copy入代码窗口。2、然后我们在事件中找到百Click事件。3、这个度时候开始编写代码测试【问Print "我是Click单击答属性!"】。4、然我们开始运行测试。5、启动后,我们在窗体空白处单击。6、这个时候我们将可以看到测试的效果。
用VB制作小程序
Option ExplicitPrivate Sub Form_Load() Randomize Label1.Caption = Int((Rnd * (999999 - 100000 + 1)) + 100000) '生成100000-999999之间的随机数 Timer1.Interval = 1000 '一秒一次 Timer1.Enabled = TrueEnd SubPrivate Sub Timer1_Timer() Static n As Integer ...