VB如何十几行代码写一个科学计算器!
效果:源码:
Private Sub Command_Click()
On Error GoTo Command_Click_Err
0 Dim ScriptControl As Object, Psw$
2 Dim code As String
100 code = "Function encodePwd" & vbCrLf & "encodePwd = " & Text1.Text & vbCrLf & "End Function"
102 Set ScriptControl = CreateObject("MSScriptControl.ScriptControl")
104 ScriptControl.Language = "VBScript"
106 ScriptControl.Timeout = -1
108 ScriptControl.AddCode code
110 Psw = ScriptControl.Run("encodePwd")
112 Text2.Text = Psw
114 Text1.SetFocus
Exit Sub
Command_Click_Err:
MsgBox "::>_<:: 有以下错误" & vbCrLf & Err.Description & vbCrLf & _
"发生在 VBS语言计算器.MainForm.Command_Click " & _
"的第 " & Erl & " 行" & vbCrLf & vbCrLf & "检查一下你的语法是否正确 :)", _
vbExclamation + vbOKOnly, "出错啦!"
Resume Next
'foot
End Sub
BY麦子 哈哈哈哈 加油~~~~~~~~~~~~~~~~~~~~~~~~~
页:
[1]