📄 uspexpress.frm
字号:
VERSION 5.00
Begin VB.Form 公式编译器系统
BorderStyle = 1 'Fixed Single
Caption = "数值计算系统"
ClientHeight = 6870
ClientLeft = 45
ClientTop = 345
ClientWidth = 10560
LinkTopic = "Form1"
MaxButton = 0 'False
MinButton = 0 'False
ScaleHeight = 6870
ScaleWidth = 10560
StartUpPosition = 1 'CenterOwner
Begin VB.Frame Frame1
BorderStyle = 0 'None
Height = 2595
Left = 240
TabIndex = 0
Top = 0
Width = 10335
Begin VB.CommandButton Command2
Caption = "数值计算"
Height = 450
Left = 8400
TabIndex = 17
Top = 1440
Width = 1755
End
Begin VB.OptionButton Option2
Caption = "角度"
Height = 255
Left = 4320
TabIndex = 16
Top = 1920
Width = 855
End
Begin VB.OptionButton Option1
Caption = "弧度"
Height = 255
Left = 4320
TabIndex = 15
Top = 1680
Width = 975
End
Begin VB.CommandButton trans
Caption = "弧度与角度转"
Height = 450
Left = 8400
TabIndex = 14
Top = 840
Width = 1755
End
Begin VB.TextBox angel
Height = 495
Left = 5400
TabIndex = 13
Text = "Text1"
Top = 1680
Width = 2415
End
Begin VB.CommandButton Command1
Caption = "退出系统"
Height = 450
Left = 8400
MaskColor = &H00C0C0FF&
TabIndex = 10
Top = 2040
Width = 1755
End
Begin VB.Frame Frame2
Height = 855
Left = 120
TabIndex = 6
Top = 1440
Width = 3585
Begin VB.Label Label1
BackStyle = 0 'Transparent
Caption = "请您在上面表达式编辑框中输入要计算的差表达式,然后点击“计算表达式”按钮"
ForeColor = &H00C00000&
Height = 855
Left = 240
TabIndex = 7
Top = 240
Width = 3360
End
End
Begin VB.TextBox txtResult
Height = 375
Left = 1200
Locked = -1 'True
TabIndex = 4
Top = 840
Width = 2355
End
Begin VB.CommandButton btnCalculate
Caption = "计算表达式"
Default = -1 'True
Height = 450
Left = 8400
TabIndex = 2
Top = 240
Width = 1755
End
Begin VB.TextBox txtExpression
Height = 375
Left = 1200
TabIndex = 1
Top = 240
Width = 6600
End
Begin VB.Label Label2
Caption = "线性判断"
ForeColor = &H00C00000&
Height = 375
Left = 4320
TabIndex = 9
Top = 840
Width = 735
End
Begin VB.Label lblLinear
BorderStyle = 1 'Fixed Single
Caption = "线性判断?"
Height = 495
Left = 5430
TabIndex = 8
Top = 840
Width = 2370
End
Begin VB.Label lblResult
Caption = "结 果"
ForeColor = &H00C00000&
Height = 240
Left = 120
TabIndex = 5
Top = 840
Width = 780
End
Begin VB.Label lblExpression
Caption = "表达式"
ForeColor = &H00C00000&
Height = 375
Left = 120
TabIndex = 3
Top = 240
Width = 780
End
End
Begin VB.Label Label4
Alignment = 2 'Center
BackStyle = 0 'Transparent
Caption = "数值计算系统"
BeginProperty Font
Name = "楷体_GB2312"
Size = 42
Charset = 134
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
ForeColor = &H000000FF&
Height = 1095
Left = 2880
TabIndex = 12
Top = 3000
Width = 6855
End
Begin VB.Label Label3
Alignment = 2 'Center
BackStyle = 0 'Transparent
Caption = "淮阴工学院计算机工程系 王渺 2004.06.07"
BeginProperty Font
Name = "楷体_GB2312"
Size = 18
Charset = 134
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
ForeColor = &H000000FF&
Height = 1695
Left = 1440
TabIndex = 11
Top = 4800
Width = 8895
End
Begin VB.Image Image1
BorderStyle = 1 'Fixed Single
Height = 4125
Left = 120
Picture = "USPEXP~1.frx":0000
Stretch = -1 'True
Top = 2640
Width = 10575
End
End
Attribute VB_Name = "公式编译器系统"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Dim y As Double
Private iEx As USPEXPRESSPARSER.USPExpression
Private Function CalculateExpression(sExpression As String, bIsLinear As Boolean) As Double
Dim sVariables(1 To 6) As String
Dim dValues(1 To 6) As Double
Dim lIndex As Integer
Dim lErrCode As Integer
sVariables(1) = "X1"
sVariables(2) = "X2"
sVariables(3) = "X3"
sVariables(4) = "X4"
sVariables(5) = "X5"
dValues(1) = y
dValues(2) = 3.1415 * 0.25
dValues(3) = 3.1415 * 0.5
dValues(4) = 3.1415 * 0.167
dValues(5) = 3.1415 * 0.333
lIndex = iEx.Parse(sExpression, sVariables, lErrCode)
If lErrCode = USPEX_NO_ERROR Then
bIsLinear = iEx.IsLinear
On Error GoTo EvaluationError_
CalculateExpression = iEx.Evaluate(dValues)
ElseIf lErrCode = USPEX_UNSUPPORTED_IN_TRIAL_VERSION Then
MsgBox "表达式目前只支持乘法(*)和加法(+)运算,如果你要计算除法(/)和减法(-),请用逆运算.", vbInformation, "运算符错误"
Else
MsgBox "无效的表达式,请仔细检查错误", vbExclamation, "表达式错误"
End If
Exit Function
EvaluationError_:
MsgBox Err.Description
End Function
Private Sub btnCalculate_Click()
Dim bIsLinear As Boolean
Me.txtResult = CalculateExpression(Me.txtExpression, bIsLinear)
lblLinear.Caption = IIf(bIsLinear, "线性", "非线性")
End Sub
Private Sub Command1_Click()
End
End Sub
Private Sub Command2_Click()
simu.Show
End Sub
Private Sub Form_Initialize()
Set iEx = New USPExpression
End Sub
Private Sub Form_Terminate()
Set iEx = Nothing
End Sub
Private Sub Form_Load()
Dim oMyFunction As New CmyFunction
iEx.UserFunctions.Add oMyFunction
Me.txtResult = ""
txtExpression.Text = " "
Me.Icon = LoadPicture("")
angel.Text = " "
End Sub
Private Sub Option1_Click()
Option1.Value = True
Option2.Value = False
End Sub
Private Sub Option2_Click()
Option2.Value = True
Option1.Value = False
End Sub
Private Sub trans_Click()
If Option1.Value = True Then
y = Val(angel.Text) * 180 / 3.1415
angel.Text = "弧度转化为" + CStr(y) + "角度"
Else
y = Val(angel.Text) * 3.1415 / 180
angel.Text = "角度转化为" + CStr(y) + "弧度"
End If
'MsgBox y
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -