动态语句求表达式值的一个例子

Private Declare Function EbExecuteLine Lib "vba6.dll" (ByVal pStringToExec As Long, ByVal Unknownn1 As Long, ByVal Unknownn2 As Long, ByVal fCheckOnly As Long) As Long
Public y As Single
Private Function ExecuteLine(sCode As String, Optional fCheckOnly As Boolean) As Boolean
    ExecuteLine = EbExecuteLine(StrPtr(sCode), 0&, 0&, Abs(fCheckOnly)) = 0
End Function


Private Sub Command1_Click()
Dim x As Single
Dim b As Boolean
Dim a As String
Cls
Form1.Scale (-10, 10)-(10, -10)
Form1.Line (-10, 0)-(10, 0), vbBlue
Form1.Line (0, 10)-(0, -10), vbBlue
a = Mid(Text1.Text, 3)
For x = -10 To 10 Step 1
        a = Replace(a, "x", CStr(x))
        b = ExecuteLine("Form1.y=" & a)
        Form1.PSet (x, y)
        DoEvents
Next x

End Sub

阅读更多
个人分类: VB
想对作者说点什么? 我来说一句

没有更多推荐了,返回首页

关闭
关闭
关闭