作者TrueFeeling (昨日之死)
看板Visual_Basic
标题Re: [VB6 ] 计算机
时间Fri Jun 10 15:13:03 2005
惨了.都看不懂T.T,
能不能解说一下整个思路是怎麽架构的,谢啦
还有GoSub,Return这些字我也不知道作用是什麽
Function我看书上(入门书啦)说,Function里面的架构:
函数名=运算式
所以这种Function的写法我也看不大懂T.T
※ 引述《fumizuki (小狮子)》之铭言:
: ※ 引述《fumizuki (小狮子)》之铭言:
: Function Eval(s As String)
: Dim p As Integer, op1 As String, op2 As String, o As String
: Static c As Integer: c = c + 1
: If c = 1 Then s = Replace(s, " ", "")
: p = InStr(s, "+")
: If p > 0 Then GoSub SplitProc: Eval = Eval(op1) + Eval(op2): GoTo EndProc
: If s Like "-*" Then p = 2 Else p = 1
: p = InStr(p, s, "-")
: If p > 0 Then
: op1 = Mid(s, p - 1, 1)
: If op1 = "+" Then
: p = p - 1: GoSub SplitProc: Eval = Eval(op1) + Eval(op2): GoTo EndProc
: ElseIf op1 = "-" Then
: p = p - 1: GoSub SplitProc: Eval = Eval(op1) - Eval(op2): GoTo EndProc
: ElseIf op1 = "*" Then
: p = p - 1: GoSub SplitProc: Eval = Eval(op1) * Eval(op2): GoTo EndProc
: ElseIf op1 = "/" Then
: p = p - 1: GoSub SplitProc: Eval = Eval(op1) / Eval(op2): GoTo EndProc
: Else
: GoSub SplitProc: Eval = Eval(op1) + Eval("-" & op2): GoTo EndProc
: End If
: End If
: p = InStr(s, "*")
: If p > 0 Then GoSub SplitProc: Eval = Eval(op1) * Eval(op2): GoTo EndProc
: p = InStr(s, "/")
: If p > 0 Then GoSub SplitProc: Eval = Eval(op1) / Eval(op2): GoTo EndProc
: Eval = Val(s)
: EndProc:
: c = c - 1: Exit Function
: SplitProc:
: op1 = Left(s, p - 1): op2 = Mid(s, p + 1): Return
: End Function
--
少年读书,如隙中窥月;
中年读书,如庭中望月;
老年读书,如台上玩月。
--
※ 发信站: 批踢踢实业坊(ptt.cc)
◆ From: 218.162.90.149