VB算24点

原创 2002年08月22日 09:45:00

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

VB.NET中怎样实现位运算

这几天一直在边学习边写一个PC应用程序,用来接收串口收到的数据,并已要求的格式保存,并将数据以实时曲线的方式绘制出来。下位机是和ADI的ads21469通信,数据时1K Hz/s的采样率,即每秒采10...
  • fengzei886
  • fengzei886
  • 2014年04月03日 19:54
  • 1834

C++实现24点游戏算法

**2017-7-18更新更新内容: 算法本身并没问题,些许小地方有bug,已经修改。如果测试还有问题,请评论告知,非常感谢!!现已上传github: 这里写链接内容#include #inclu...
  • qq_16013649
  • qq_16013649
  • 2015年09月24日 11:39
  • 2534

24点游戏的编程算法(C语言实现)

#include #include #include #define LING 1E-6 #define CONT 4 #define VOLUE 24 float number[CONT]...
  • CTO_51
  • CTO_51
  • 2013年04月23日 00:09
  • 5585

VB 算24点(含源码)

  • 2009年06月06日 19:44
  • 9KB
  • 下载

vb写的算24点

  • 2013年03月18日 17:37
  • 3KB
  • 下载

一个求24点所有可能解的VB源代码及程序实现

求24点的VB的不多。网上求一种解的代码多,但是求所有解的代码和程序更不多。最近花了2天做了一个求24点所有解的VB小程序。...
  • zhouyun646356977
  • zhouyun646356977
  • 2015年10月10日 14:22
  • 644

24点网络对战vb客户端加服务器

  • 2009年11月13日 11:13
  • 2.7MB
  • 下载

24点(vb版)

  • 2006年03月16日 00:00
  • 66KB
  • 下载

简单24点计算器(VB作品)

  • 2015年07月14日 17:26
  • 36KB
  • 下载

VB_24点小游戏

  • 2016年10月31日 09:21
  • 3.52MB
  • 下载
内容举报
返回顶部
收藏助手
不良信息举报
您举报文章:VB算24点
举报原因:
原因补充:

(最多只允许输入30个字)