Home > Software engineering >  Vb if based on the input of the formula to calculate the results.
Vb if based on the input of the formula to calculate the results.

Time:09-21

Known a=10
B=3
The text box input a * b
The trigger condition, results of 30

How to solve? What function,

CodePudding user response:

Use the Replace function will be replaced with the variable character, the said number,

CodePudding user response:

 'engineering add components to Microsoft Script Control 1.0 
'-- -- -- -- -- -- -- --
'Form1
'put a ScriptControl, a TextBox, a CommandButton
Option Explicit

Private Sub Command1_Click ()
With ScriptControl1
. Language="VBScript"
The Reset
'to add the known variables'
. AddCode "a=10
". AddCode "b=3"
'formula'
MsgBox. Eval (Text1)
End With
End Sub

Private Sub Form_Load ()
Text1. Text="a * b" 'default formula'
End Sub

CodePudding user response:

Must be a text box
Want to simple, if you can just text box tag
Such as text, text x text2. Text

CodePudding user response:

refer to the second floor Tiger_Zhao response:
 'engineering add components to Microsoft Script Control 1.0 
'-- -- -- -- -- -- -- --
'Form1
'put a ScriptControl, a TextBox, a CommandButton
Option Explicit

Private Sub Command1_Click ()
With ScriptControl1
. Language="VBScript"
The Reset
'to add the known variables'
. AddCode "a=10
". AddCode "b=3"
'formula'
MsgBox. Eval (Text1)
End With
End Sub

Private Sub Form_Load ()
Text1. Text="a * b" 'default formula'
End Sub


This control with good, can be an IDE,
  • Related