MSSCRIPT.OCX如何进行方式程式计算?

解决方案 »

  1.   

    '这个东东我喜欢 "不引用" Msscript.ocx , 你要引用的我就贴引用的吧.'添加 Text1  Text2  Command1'在工程部件的属性窗里将Microsoft Script Control 1.0 打勾应用 ,并在工具栏内将它加入窗体
    'Msscript.ocx'在Text1里面的表达式+-*/或开方,立方随你, 例 25的平方根 sqr(25)=5 ,8 的3次幂 8 ^ 3 = 512Dim X1!, Y1!
    Private Sub Form_Activate()
       Me.Move (Screen.Width - Me.Width) \ 2, (Screen.Height - Me.Height) \ 2
       Me.KeyPreview = True
       Text1.Text = "": Text2.Text = "": Text1.SetFocus
    End SubPrivate Sub Command1_Click()
       Text2.Text = ""
       ScriptControl1.Language = "VBScript"
       ScriptControl1.ExecuteStatement "x1 = " & X1
       Y1 = ScriptControl1.Eval(Text1.Text)
       ScriptControl1.Reset
       Text2.Text = CStr(Y1)
    End SubPrivate Sub Text1_KeyPress(KeyAscii As Integer)
       If KeyAscii <> 0 Then
          Select Case KeyAscii
             Case 27
                End
             Case 13
                Command1_Click
             Case Else
          End Select
       End If
    End Sub'Text1中随你输入下面的, 玩玩看吧
    'Chr(65) = a
    'Chr(97) = a
    'Asc("a") = 97
    'Asc("A") = 65
    'Hex(255) = FF '10转16进制
    'Oct(1204) = 2264 '10转8进制
    '25 的平方根 Sqr(25) = 5
    '8 的3次幂 8 ^ 3 = 512
      

  2.   

    我说的不是这意思,我是说能不能你方程式那样的
    a=3
    b=4
    x=a+b
    就能算出x=7
      

  3.   

    '不需要引用 Msscript.ocx 的方法'添加 Text1Private Sub Text1_KeyPress(KeyAscii As Integer)
       On Error GoTo Errhandler
       If KeyAscii = 13 Then
          Set sc = CreateObject("ScriptControl")
          sc.Language = "VBScript"
          Text1.Text = sc.EVal(Text1)
          Set sc = Nothing: KeyAscii = 0
       End If
    Errhandler:
       If Err > 0 Then MsgBox Err.Description
    End Sub