完整版基于vb的直线插补与圆弧插补实验Word格式.docx
《完整版基于vb的直线插补与圆弧插补实验Word格式.docx》由会员分享,可在线阅读,更多相关《完整版基于vb的直线插补与圆弧插补实验Word格式.docx(23页珍藏版)》请在冰豆网上搜索。
;
Xe;
"
"
Ye;
)"
IfText1.Text=noneOrText2.Text=noneThenMsgBox"
请输入加工终点坐标值。
"
Text3.Text=0
Text4.Text=0
Text5.Text=0
EndSub
PrivateSubCommand2_Click()
DimsumAsInteger
Xm=Val(Text3.Text)
Ym=Val(Text4.Text)
m=Val(Text5.Text)
sum=Xe*Ym-Xm*Ye
'
第一象限开始
IfXe>
0AndYe>
0Andsum>
=0ThenPicture1.Line(Xm,Ym)-(Xm+1,Ym),vbRed:
Text3.Text=Xm+1
0Andsum<
0ThenPicture1.Line(Xm,Ym)-(Xm,Ym+1),vbRed:
Text4.Text=Ym+1
IfAbs(Xm)+Abs(Ym)>
=Abs(Xe)+Abs(Ye)-1ThenMsgBox"
加工完毕!
第二象限开始
IfXe<
=0ThenPicture1.Line(Xm,Ym)-(Xm,Ym+1),vbRed:
0ThenPicture1.Line(Xm,Ym)-(Xm-1,Ym),vbRed:
Text3.Text=Xm-1
=Abs(Xe)+Abs(Ye)+1ThenMsgBox"
第三象限开始
0AndYe<
=0ThenPicture1.Line(Xm,Ym)-(Xm-1,Ym),vbRed:
0ThenPicture1.Line(Xm,Ym)-(Xm,Ym-1),vbRed:
Text4.Text=Ym-1
=Abs(Xe)+Abs(Ye)ThenMsgBox"
第四象限开始
=0ThenPicture1.Line(Xm,Ym)-(Xm,Ym-1),vbRed:
0ThenPicture1.Line(Xm,Ym)-(Xm+1,Ym),vbRed:
Text5.Text=Abs(Val(Text3.Text))+Abs(Val(Text4.Text))
PrivateSubCommand3_Click()
Form2.Hide
Form1.Show
数字积分器法圆弧插补
Text6.Text=0
Text7.Text=0
ax=Val(Text3.Text)
ay=Val(Text4.Text)
n=Val(Text7.Text)
Xm=Val(Text5.Text)
Ym=Val(Text6.Text)
终点判断
a=ax+Abs(Xe)
Ifa<
16ThenText3.Text=a
Ifa>
=16ThenText3.Text=a-16
=32ThenText3.Text=a-32
b=ay+Abs(Ye)
Ifb<
16ThenText4.Text=b
Ifb>
=16ThenText4.Text=b-16
=32ThenText4.Text=b-32
0Anda>
=16Andb<
16ThenPicture1.Line(Xm,Ym)-(Xm+1,Ym),vbRed:
Text7.Text=n+1:
Text5.Text=Xm+1
=16Andb>
=16ThenPicture1.Line(Xm,Ym)-(Xm+1,Ym+1),vbRed:
Text7.Text=n+2:
Text5.Text=Xm+1:
Text6.Text=Ym+1
0Anda<
16Andb>
=16ThenPicture1.Line(Xm,Ym)-(Xm,Ym+1),vbRed:
Ifn=Abs(Xe)+Abs(Ye)ThenMsgBox"
错误:
已经加工完毕,无法继续加工,请点击复位!
16ThenPicture1.Line(Xm,Ym)-(Xm-1,Ym),vbRed:
Text5.Text=Xm-1
=16ThenPicture1.Line(Xm,Ym)-(Xm-1,Ym+1),vbRed:
Text5.Text=Xm-1:
=16ThenPicture1.Line(Xm,Ym)-(Xm-1,Ym-1),vbRed:
Text6.Text=Ym-1
=16ThenPicture1.Line(Xm,Ym)-(Xm,Ym-1),vbRed:
=16ThenPicture1.Line(Xm,Ym)-(Xm+1,Ym-1),vbRed:
结束
Ifn>
=Abs(Xe)+Abs(Ye)ThenText7.Text=Abs(Xe)+Abs(Ye)
Ifn=Abs(Xe)+Abs(Ye)-1Anda>
=16ThenMsgBox"
Ifn=Abs(Xe)+Abs(Ye)-1Andb>
Ifn=Abs(Xe)+Abs(Ye)-2Anda>
Form3.Hide
DimR,a,b,Ym,Xm,Xe,Ye
R=Val(Text1.Text)
a=Val(Text2.Text)
b=Val(Text3.Text)
Xe=Val(Text4.Text)
Ye=Val(Text5.Text)
Xm=Val(Text6.Text)
Ym=Val(Text7.Text)
Picture1.Scale(-Picture1.ScaleWidth/4,Picture1.ScaleHeight/4)-(Picture1.ScaleWidth/4,-Picture1.ScaleHeight/4)
Picture1.Circle(0,0),Text1,vbBlue,Text2,Text3
Text1.Text="
Text2.Text="
Text3.Text="
Text6.Text="
Text7.Text="
DimsumAsSingle,Y,X
IfOption1Then'
逆圆弧
Y=Sqr(R^2-Xm^2)
X=Sqr(R^2-Ym^2)
IfXm=RAndYm=0Then'
一象限
Picture1.Line(Xm,Ym)-(Xm,Ym+1),vbRed:
Ym=Ym+1
Text7.Text=Ym+1
EndIf
IfXm>
0AndYm>
0Then
=XThen
Picture1.Line(Xm,Ym)-(Xm-1,Ym),vbRed:
Text6.Text=Xm-1:
Xm=Xm-1
Else
IfYm<
YThen
Text7.Text=Ym+1:
IfXm=XeAndYm=YeThen
MsgBox"
加工完成!
EndIf
IfXm=0AndYm=RThen'
二象限
Text6.Text=Xm-1
IfXm<
IfYm>
=YThen
Picture1.Line(Xm,Ym)-(Xm,Ym-1),vbRed:
Ym=Ym-1:
Text7.Text=Ym-1
-XThen
Xm=Xm-1:
IfXm=-RAndYm=0Then'
三象限
Ym=Ym-1
0AndYm<
-YThen
Picture1.Line(Xm,Ym)-(Xm+1,Ym),vbRed:
Xm=Xm+1:
Text6.Text=Xm+1
IfXm=0AndYm=-RThen'
四象限
Picture1.Line(Xm+1,Ym)-(Xm,Ym),vbRed:
IfXm>
Ym=Ym+1:
IfXm<
XThen
IfOption2Then'
顺圆弧
Y=Sqr(R^2-Xm^2)
X=Sqr(R^2-Ym^2)
第一象限
第二象限
第三象限
IfXm=RAndYm=0Then'
第四象限
Form4.Hide
DimR,a,b,Ym,Xm,Xe,Ye,ax,ay,m,n,s,t
b=Val(Text3.Te