本人VB菜鳥,想分離這段語言中涉及到的函式,求高手幫我解讀一下,萬分感謝!
Sub G01(X As Single, Y As Single, Z As Single) 'G01程序
Dim X1 As Single, Y1 As Single, SPointX As Single, SPointY As Single, I As Single, L As Single
On Error GoTo errhand
If X = CurrentNX And Y = CurrentNY And Z = CurrentNZ Then
Exit Sub
End If
If StopRun = True Then
Exit Sub
End If
frmmain.lblState.Caption = "直線插補|" & "起點: X" & CurrentNX & " Y" & CurrentNY & " Z" & CurrentNZ & "終點: X" & X & " Y" & Y & " Z" & Z
SPointX = CurrentNX
SPointY = CurrentNY
If X <> CurrentNX Then
Dim K As Single
K = (Y - CurrentNY) / (X - CurrentNX)
For I = CurrentNX To X Step Sgn(X - CurrentNX)
Y1 = SPointY + K * (I - SPointX)
X1 = I
Call DrawLine(CurrentNX, CurrentNY, X1, Y1)
CurrentNX = X1
CurrentNY = Y1
CurrentNZ = Z
Next I
Else
For I = CurrentNY To Y Step Sgn(Y - CurrentNY)
Y1 = I
X1 = CurrentNX
Call DrawLine(CurrentNX, CurrentNY, X1, Y1)
CurrentNX = X1
CurrentNY = Y1
CurrentNZ = Z
If X = CurrentNX And Y = CurrentNY And Z = CurrentNZ Then
Exit Sub
End If
Next I
End If
Exit Sub
errhand:
If StopRun = False Then
MsgBox "程式發生錯誤,請檢查G代碼!", vbOKOnly, "錯誤"
End If
End Sub
轉載請註明出處,本文鏈接:https://www.uj5u.com/gongcheng/95300.html
標籤:VB基礎類
上一篇:VB6能否控制多點觸摸?
下一篇:vb通信求助
