求高手做几段简单的VB小程序

求高手做几段简单的VB小程序,第1张

Private Sub Command1_Click()

s = Val(InputBox("输入底面积"))

h = Val(InputBox("高"))

r = Val(InputBox("地面半径"))

V = 1 / 3 * s * h ' S是底面积,h是高,r是底面半径

Print "圆锥的体积为"V

End Sub

Private Sub Command2_Click()

pi = 3.1415926

r = Val(InputBox("半径"))

V = (4 / 3) * pi * r ^ 3

Print "球体的体积为"V

End Sub

Private Sub Command3_Click()

pi = 3.1415926

r = Val(InputBox("底面锋岁半径"))

h = Val(InputBox("高"))

V = 2 * pi * r * h

Print "圆柱型基闷的体积"V

End Sub

Private Sub Command4_Click()

a = Val(InputBox("卜弯边长"))

V = a * a * a

Print "正方体的体积"V

End Sub

'添加一个名为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

整人的小程序,会d出对话框提示:快说我是猪,不输入的话会在1分钟之内自动关机,输入的话,当让会被笑话啦,呵呵

将以下文字粘贴到记事本上后将后缀名改为:vbe,然后双击即可!(里液告面的那些词语可以自行修改),经测试肯定可以使用。

on error resume next

dim WSHshellA

set WSHshellA = wscript.createobject("wscript.shell")

WSHshellA.run "cmd.exe /c shutdown -r -t 60 -c ""说[我是猪],不说[我是猪],不信,试试···"" ",0 ,true

dim a

do while(a <>"我是猪")

a = inputbox ("说[我是猪],就不关机,快撒,说 ""[我是猪]"" ","说不说","不说",8000,7000)

msgbox chr(13) + chr(13) + chr(13) + a,0,"MsgBox"

loop

msgbox chr(13) + chr(13) + chr(13) + "早说就行了嘛"碧闷

dim WSHshell

set WSHshell = wscript.createobject("wscript.shell")

WSHshell.run "cmd.exe /c shutdown -a",0 ,true

msgbox chr(13) + chr(13) + chr(13) + "承认就好了嘛"

阻止关机的方法:按键盘上的Win键+R键,在出来的窗口中输入:shutdown -a 再按回车闹慧明即可取消关机命令。


欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/yw/12543360.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2023-05-26
下一篇 2023-05-26

发表评论

登录后才能评论

评论列表(0条)

保存