分享
 
 
 

VB算24点

王朝vb·作者佚名  2006-01-08
窄屏简体版  字體: |||超大  

VERSION 5.00

Begin VB.Form frmMain

BorderStyle = 1 'Fixed Single

Caption = " 24点"

ClientHeight = 4020

ClientLeft = 45

ClientTop = 330

ClientWidth = 5325

Icon = "Form1.frx":0000

LinkTopic = "Form1"

MaxButton = 0 'False

MinButton = 0 'False

ScaleHeight = 4020

ScaleWidth = 5325

StartUpPosition = 3 '窗口缺省

Begin VB.Timer t

Interval = 20000

Left = 4440

Top = 2310

End

Begin VB.CommandButton cmdExit

Caption = "退出"

Height = 525

Left = 3330

TabIndex = 6

Top = 3030

Width = 975

End

Begin VB.CommandButton cmdDo

Caption = "求解"

Height = 525

Left = 2160

TabIndex = 1

Top = 3030

Width = 975

End

Begin VB.CommandButton cmdMake

Caption = "出题"

Height = 525

Left = 960

TabIndex = 0

Top = 3030

Width = 975

End

Begin VB.Label lresult

AutoSize = -1 'True

BeginProperty Font

Name = "宋体"

Size = 15.75

Charset = 134

Weight = 400

Underline = 0 'False

Italic = 0 'False

Strikethrough = 0 'False

EndProperty

Height = 315

Left = 450

TabIndex = 7

Top = 1560

Width = 165

End

Begin VB.Label lNumberD

AutoSize = -1 'True

Caption = "0"

BeginProperty Font

Name = "宋体"

Size = 48

Charset = 134

Weight = 400

Underline = 0 'False

Italic = 0 'False

Strikethrough = 0 'False

EndProperty

ForeColor = &H0000C000&

Height = 960

Left = 4200

TabIndex = 5

Top = 300

Width = 480

End

Begin VB.Label lNumberB

AutoSize = -1 'True

Caption = "0"

BeginProperty Font

Name = "宋体"

Size = 48

Charset = 134

Weight = 400

Underline = 0 'False

Italic = 0 'False

Strikethrough = 0 'False

EndProperty

ForeColor = &H0080FF80&

Height = 960

Left = 1680

TabIndex = 4

Top = 300

Width = 480

End

Begin VB.Label lNumberC

AutoSize = -1 'True

Caption = "0"

BeginProperty Font

Name = "宋体"

Size = 48

Charset = 134

Weight = 400

Underline = 0 'False

Italic = 0 'False

Strikethrough = 0 'False

EndProperty

ForeColor = &H0000FF00&

Height = 960

Left = 2940

TabIndex = 3

Top = 300

Width = 480

End

Begin VB.Label lNumberA

AutoSize = -1 'True

Caption = "0"

BeginProperty Font

Name = "宋体"

Size = 48

Charset = 134

Weight = 400

Underline = 0 'False

Italic = 0 'False

Strikethrough = 0 'False

EndProperty

ForeColor = &H00C0FFC0&

Height = 960

Left = 420

TabIndex = 2

Top = 300

Width = 480

End

End

Attribute VB_Name = "frmMain"

Attribute VB_GlobalNameSpace = False

Attribute VB_Creatable = False

Attribute VB_PredeclaredId = True

Attribute VB_Exposed = False

Dim NumberA, NumberB, NumberC, NumberD As Single

Dim A, B, C, D As Single

Dim Jieguo As Single

Dim ResultExpression As String

Dim i As Integer

Dim Num As Boolean

Sub Kind(i As Integer)

Select Case i

Case 1

A = NumberA: B = NumberB: C = NumberC: D = NumberD

Case 2

A = NumberA: B = NumberB: D = NumberC: C = NumberD

Case 3

A = NumberA: C = NumberB: B = NumberC: D = NumberD

Case 4

A = NumberA: C = NumberB: D = NumberC: B = NumberD

Case 5

A = NumberA: D = NumberB: B = NumberC: C = NumberD

Case 6

A = NumberA: D = NumberB: C = NumberC: B = NumberD

Case 7

B = NumberA: A = NumberB: C = NumberC: D = NumberD

Case 8

B = NumberA: A = NumberB: D = NumberC: C = NumberD

Case 9

B = NumberA: C = NumberB: A = NumberC: D = NumberD

Case 10

B = NumberA: C = NumberB: D = NumberC: A = NumberD

Case 11

B = NumberA: D = NumberB: A = NumberC: C = NumberD

Case 12

B = NumberA: D = NumberB: C = NumberC: A = NumberD

Case 13

C = NumberA: A = NumberB: B = NumberC: D = NumberD

Case 14

C = NumberA: A = NumberB: D = NumberC: B = NumberD

Case 15

C = NumberA: B = NumberB: A = NumberC: D = NumberD

Case 16

C = NumberA: B = NumberB: D = NumberC: A = NumberD

Case 17

C = NumberA: D = NumberB: A = NumberC: B = NumberD

Case 18

C = NumberA: D = NumberB: B = NumberC: A = NumberD

Case 19

D = NumberA: A = NumberB: B = NumberC: C = NumberD

Case 20

D = NumberA: A = NumberB: C = NumberC: B = NumberD

Case 21

D = NumberA: B = NumberB: A = NumberC: C = NumberD

Case 22

D = NumberA: B = NumberB: C = NumberC: A = NumberD

Case 23

D = NumberA: C = NumberB: A = NumberC: B = NumberD

Case 24

D = NumberA: C = NumberB: B = NumberC: A = NumberD

End Select

End Sub

Private Sub cmdDo_Click()

For j = 1 To 30

Select Case j

Case 1

For i = 1 To 1

Call Kind(i)

Jieguo = A + B + C + D

If Jieguo = 24 Then

ResultExpression = A & "+" & B & "+" & C & "+" & D & "=24"

Num = True

lresult.Caption = ResultExpression

Exit For

End If

Next i

Case 2

For i = 1 To 24

Call Kind(i)

Jieguo = A + B + C - D

If Jieguo = 24 Then

ResultExpression = A & "+" & B & "+" & C & "-" & D & "=24"

Num = True

lresult.Caption = ResultExpression

Exit For

End If

Next i

Case 3

For i = 1 To 24

Call Kind(i)

Jieguo = A * B + C + D

If Jieguo = 24 Then

ResultExpression = A & "*" & B & "+" & C & "+" & D & "=24"

Num = True

lresult.Caption = ResultExpression

Exit For

End If

Next i

Case 4

For i = 1 To 24

Call Kind(i)

Jieguo = A * B + C - D

If Jieguo = 24 Then

ResultExpression = A & "*" & B & "+" & C & "-" & D & "=24"

Num = True

lresult.Caption = ResultExpression

Exit For

End If

Next i

Case 5

For i = 1 To 24

Call Kind(i)

Jieguo = A * B * C + D

If Jieguo = 24 Then

ResultExpression = A & "*" & B & "*" & C & "+" & D & "=24"

Num = True

lresult.Caption = ResultExpression

Exit For

End If

Next i

Case 6

For i = 1 To 24

Call Kind(i)

Jieguo = A * B * C - D

If Jieguo = 24 Then

ResultExpression = A & "*" & B & "*" & C & "-" & D & "=24"

Num = True

lresult.Caption = ResultExpression

Exit For

End If

Next i

Case 7

For i = 1 To 24

Call Kind(i)

Jieguo = A * B * C * D

If Jieguo = 24 Then

ResultExpression = A & "*" & B & "*" & C & "*" & D & "=24"

Num = True

lresult.Caption = ResultExpression

Exit For

End If

Next i

Case 8

For i = 1 To 24

Call Kind(i)

Jieguo = A * B + C * D

If Jieguo = 24 Then

ResultExpression = A & "*" & B & "+" & C & "*" & D & "=24"

Num = True

lresult.Caption = ResultExpression

Exit For

End If

Next i

Case 9

For i = 1 To 24

Call Kind(i)

Jieguo = A * B - C * D

If Jieguo = 24 Then

ResultExpression = A & "*" & B & "-" & C & "*" & D & "=24"

Num = True

lresult.Caption = ResultExpression

Exit For

End If

Next i

Case 10

For i = 1 To 24

Call Kind(i)

Jieguo = A / B + C + D

If Jieguo = 24 Then

ResultExpression = A & "/" & B & "+" & C & "+" & D & "=24"

Num = True

lresult.Caption = ResultExpression

Exit For

End If

Next i

Case 11

For i = 1 To 24

Call Kind(i)

Jieguo = A * B / C + D

If Jieguo = 24 Then

ResultExpression = A & "*" & B & "/" & C & "+" & D & "=24"

Num = True

lresult.Caption = ResultExpression

Exit For

End If

Next i

Case 12

For i = 1 To 24

Call Kind(i)

Jieguo = A * B / C - D

If Jieguo = 24 Then

ResultExpression = A & "*" & B & "/" & C & "-" & D & "=24"

Num = True

lresult.Caption = ResultExpression

Exit For

End If

Next i

Case 13

For i = 1 To 24

Call Kind(i)

Jieguo = A * B * C / D

If Jieguo = 24 Then

ResultExpression = A & "*" & B & "*" & C & "/" & D & "=24"

Num = True

lresult.Caption = ResultExpression

Exit For

End If

Next i

Case 14

For i = 1 To 24

Call Kind(i)

Jieguo = A * B / C / D

If Jieguo = 24 Then

ResultExpression = A & "*" & B & "/" & C & "/" & D & "=24"

Num = True

lresult.Caption = ResultExpression

Exit For

End If

Next i

Case 15

For i = 1 To 24

Call Kind(i)

Jieguo = (A + B) * C / D

If Jieguo = 24 Then

ResultExpression = "(" & A & "+" & B & ")*" & C & "/" & D & "=24"

Num = True

lresult.Caption = ResultExpression

Exit For

End If

Next i

Case 16

For i = 1 To 24

Call Kind(i)

Jieguo = (A + B) * C * D

If Jieguo = 24 Then

ResultExpression = "(" & A & "+" & B & ")*" & C & "*" & D & "=24"

Num = True

lresult.Caption = ResultExpression

Exit For

End If

Next i

Case 17

For i = 1 To 24

Call Kind(i)

Jieguo = (A + B) * (C + D)

If Jieguo = 24 Then

ResultExpression = "(" & A & "+" & B & ")*(" & C & "+" & D & ")=24"

Num = True

lresult.Caption = ResultExpression

Exit For

End If

Next i

Case 18

For i = 1 To 24

Call Kind(i)

Jieguo = (A + B) * (C - D)

If Jieguo = 24 Then

ResultExpression = "(" & A & "+" & B & ")*(" & C & "-" & D & ")=24"

Num = True

lresult.Caption = ResultExpression

Exit For

End If

Next i

Case 19

For i = 1 To 24

Call Kind(i)

Jieguo = (A - B) * (C - D)

If Jieguo = 24 Then

ResultExpression = "(" & A & "-" & B & ")*(" & C & "-" & D & ")=24"

Num = True

lresult.Caption = ResultExpression

Exit For

End If

Next i

Case 20

For i = 1 To 24

Call Kind(i)

Jieguo = (A - B) * C / D

If Jieguo = 24 Then

ResultExpression = "(" & A & "-" & B & ")*" & C & "/" & D & "=24"

Num = True

lresult.Caption = ResultExpression

Exit For

End If

Next i

Case 21

For i = 1 To 24

Call Kind(i)

Jieguo = (A - B) * C * D

If Jieguo = 24 Then

ResultExpression = "(" & A & "-" & B & ")*" & C & "*" & D & "=24"

Num = True

lresult.Caption = ResultExpression

Exit For

End If

Next i

Case 22

For i = 1 To 24

Call Kind(i)

Jieguo = (A + B + C) * D

If Jieguo = 24 Then

ResultExpression = "(" & A & "+" & B & "+" & C & ")*" & D & "=24"

Num = True

lresult.Caption = ResultExpression

Exit For

End If

Next i

Case 23

For i = 1 To 24

Call Kind(i)

Jieguo = (A + B + C) / D

If Jieguo = 24 Then

ResultExpression = "(" & A & "+" & B & "+" & C & ")/" & D & "=24"

Num = True

lresult.Caption = ResultExpression

Exit For

End If

Next i

Case 24

For i = 1 To 24

Call Kind(i)

Jieguo = (A + B - C) * D

If Jieguo = 24 Then

ResultExpression = "(" & A & "+" & B & "-" & C & ")*" & D & "=24"

Num = True

lresult.Caption = ResultExpression

Exit For

End If

Next i

Case 25

For i = 1 To 24

Call Kind(i)

Jieguo = A * (B + C) + D

If Jieguo = 24 Then

ResultExpression = A & "*(" & B & "+" & C & ")+" & D & "=24"

Num = True

lresult.Caption = ResultExpression

Exit For

End If

Next i

Case 26

For i = 1 To 24

Call Kind(i)

Jieguo = A * (B - C) + D

If Jieguo = 24 Then

ResultExpression = A & "*(" & B & "-" & C & ")+" & D & "=24"

Num = True

lresult.Caption = ResultExpression

Exit For

End If

Next i

Case 27

For i = 1 To 24

Call Kind(i)

Jieguo = A * (B + C) - D

If Jieguo = 24 Then

ResultExpression = A & "*(" & B & "+" & C & ")-" & D & "=24"

Num = True

lresult.Caption = ResultExpression

Exit For

End If

Next i

Case 28

For i = 1 To 24

Call Kind(i)

Jieguo = A * (B - C) - D

If Jieguo = 24 Then

ResultExpression = A & "*(" & B & "-" & C & ")-" & D & "=24"

Num = True

lresult.Caption = ResultExpression

Exit For

End If

Next i

Case 29

For i = 1 To 24

Call Kind(i)

Jieguo = A + (B + C) / D

If Jieguo = 24 Then

ResultExpression = A & "+(" & B & "+" & C & ")/" & D & "=24"

Num = True

lresult.Caption = ResultExpression

Exit For

End If

Next i

Case 30

ResultExpression = "无解"

Num = True

lresult.Caption = ResultExpression

End Select

If Num = True Then Exit For

Next j

End Sub

Private Sub cmdExit_Click()

End

End Sub

Private Sub cmdMake_Click()

Randomize

NumberA = Int(Rnd * 10) + 1

NumberB = Int(Rnd * 10) + 1

NumberC = Int(Rnd * 10) + 1

NumberD = Int(Rnd * 10) + 1

lNumberA.Caption = NumberA

lNumberB.Caption = NumberB

lNumberC.Caption = NumberC

lNumberD.Caption = NumberD

lresult.Caption = "请按求解键!"

cmdDo.Enabled = True

Num = False

End Sub

Private Sub Form_Load()

cmdDo.Enabled = False

t.Enabled = False

lresult.Caption = "请按出题键!"

Num = False

End Sub

 
 
 
免责声明:本文为网络用户发布,其观点仅代表作者个人观点,与本站无关,本站仅提供信息存储服务。文中陈述内容未经本站证实,其真实性、完整性、及时性本站不作任何保证或承诺,请读者仅作参考,并请自行核实相关内容。
2023年上半年GDP全球前十五强
 百态   2023-10-24
美众议院议长启动对拜登的弹劾调查
 百态   2023-09-13
上海、济南、武汉等多地出现不明坠落物
 探索   2023-09-06
印度或要将国名改为“巴拉特”
 百态   2023-09-06
男子为女友送行,买票不登机被捕
 百态   2023-08-20
手机地震预警功能怎么开?
 干货   2023-08-06
女子4年卖2套房花700多万做美容:不但没变美脸,面部还出现变形
 百态   2023-08-04
住户一楼被水淹 还冲来8头猪
 百态   2023-07-31
女子体内爬出大量瓜子状活虫
 百态   2023-07-25
地球连续35年收到神秘规律性信号,网友:不要回答!
 探索   2023-07-21
全球镓价格本周大涨27%
 探索   2023-07-09
钱都流向了那些不缺钱的人,苦都留给了能吃苦的人
 探索   2023-07-02
倩女手游刀客魅者强控制(强混乱强眩晕强睡眠)和对应控制抗性的关系
 百态   2020-08-20
美国5月9日最新疫情:美国确诊人数突破131万
 百态   2020-05-09
荷兰政府宣布将集体辞职
 干货   2020-04-30
倩女幽魂手游师徒任务情义春秋猜成语答案逍遥观:鹏程万里
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案神机营:射石饮羽
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案昆仑山:拔刀相助
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案天工阁:鬼斧神工
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案丝路古道:单枪匹马
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案镇郊荒野:与虎谋皮
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案镇郊荒野:李代桃僵
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案镇郊荒野:指鹿为马
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案金陵:小鸟依人
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案金陵:千金买邻
 干货   2019-11-12
 
推荐阅读
 
 
 
>>返回首頁<<
 
靜靜地坐在廢墟上,四周的荒凉一望無際,忽然覺得,淒涼也很美
© 2005- 王朝網路 版權所有