《直线插补VB编程》由会员分享,可在线阅读,更多相关《直线插补VB编程(2页珍藏版)》请在金锄头文库上搜索。
1、数控技术直线插补vb编程四个象限都可以软件连接网址:http:/ Sub Command1_Click() Dim Xe As Integer, Ye As Integer Xe = Text3: Ye = Text4: Form1.Cls: Picture1.Cls: Picture2.Cls: List1.Clear If Xe 0 Then If Ye 0 Then Picture2.Print 第一象限: Call sub1 Else Picture2.Print 第四象限: Call sub4 End If Else If Ye 0 Then Picture2.Print 第二象限:
2、 Call sub2 Else Picture2.Print 第三象限: Call sub3 End If End If Picture1.ForeColor = vbGreen: Picture1.DrawWidth = 2 If Xe 0 Then If Ye 0 Then Picture1.Line (60, 5500)-(60 + 400 * Xe, 5500 - 400 * Ye) 第一象限 Else Picture1.Line (50, 50)-(50 + 400 * Int(Xe), 50 + 400 * Int(Abs(Ye) 第四象限 End If Else If Ye 0
3、Then Picture1.Line (5500, 5500)-(5500 - 400 * Int(Abs(Xe), 5500 - 400 * Int(Ye) 第二象限 Else Picture1.Line (5500, 50)-(5500 + 400 * Int(Xe), 50 - 400 * Int(Ye) 第三象限 End If End IfEnd SubPrivate Sub sub1() 第一象限 Picture1.ForeColor = vbBlack: Picture1.DrawWidth = 2 Picture1.Line (60, 50)-(60, 5550): Pictur
4、e1.Line (10, 5500)-(5500, 5500) Picture1.Line (100, 90)-(60, 50): Picture1.Line (20, 90)-(60, 50) Picture1.Line (5460, 5460)-(5500, 5500): Picture1.Line (5460, 5540)-(5500, 5500)End SubPrivate Sub sub2() 第二象限 Picture1.ForeColor = vbBlack: Picture1.DrawWidth = 2 Picture1.Line (5500, 50)-(5500, 5550):
5、 Picture1.Line (60, 5500)-(5550, 5500) Picture1.Line (5450, 90)-(5500, 50): Picture1.Line (5540, 90)-(5500, 50) Picture1.Line (100, 5450)-(60, 5500): Picture1.Line (100, 5550)-(60, 5500)End SubPrivate Sub sub3() 第三象限 Picture1.ForeColor = vbBlack: Picture1.DrawWidth = 2 Picture1.Line (5500, 50)-(5500
6、, 5500): Picture1.Line (5500, 50)-(500, 50) Picture1.Line (5400, 5400)-(5500, 5500): Picture1.Line (5550, 5400)-(5500, 5500) Picture1.Line (600, 10)-(500, 50): Picture1.Line (600, 90)-(500, 50)End SubPrivate Sub sub4() 第四象限 Picture1.ForeColor = vbBlack: Picture1.DrawWidth = 2 Picture1.Line (50, 50)-
7、(50, 5500): Picture1.Line (50, 50)-(5500, 50) Picture1.Line (90, 5500)-(50, 5550): Picture1.Line (10, 5500)-(50, 5550) Picture1.Line (5450, 10)-(5500, 50): Picture1.Line (5450, 90)-(5500, 50)End SubPrivate Sub Command2_Click() Dim Xe As Integer, Ye As Integer Xe = Text3: Ye = Text4: Form1.Cls Dim i,
8、 k, m, j, l, g, s, F(999), n As Integer m = 0: i = 1: k = 0: F(m) = 0 Picture1.ForeColor = vbRed: Picture1.DrawWidth = 2 j = Int(Abs(Xe) + Int(Abs(Ye): Form1.CurrentX = 200: Form1.CurrentY = 200 Print 初始:进给方向 & F(m)= 0 & Xe= & Xe & Ye= & Ye & = & j For n = 1 To Int(Abs(Xe) + Int(Abs(Ye) If F(m) = 0
9、And j 0 Then m = m + 1: l = l + 1 F(m) = F(m - 1) - Int(Abs(Text4) If Xe 0 Then If Ye 0 Then Picture1.Line (50 + 400 * (l - 1), 5500 - k * 400)-(50 + 400 * (l), 5500 - k * 400) Else Picture1.Line (50 + 400 * (l - 1), 50 + k * 400)-(50 + 400 * (l), 50 + k * 400) End If Else If Ye 0 Then Picture1.Line
10、 (5500 - 400 * (l - 1), 5500 - k * 400)-(5500 - 400 * (l), 5500 - k * 400) Else Picture1.Line (5500 - 400 * (l - 1), 50 + k * 400)-(5500 - 400 * (l), 50 + k * 400) End If End If Form1.CurrentX = 200: Form1.CurrentY = 200 + n * 300 List1.AddItem 第 & m & 步 & x F( & m & )= & F(m) & & x=- & l & & y=- &
11、k & = & j - n Else k = k + 1: m = m + 1 If Xe 0 Then If Ye 0 Then Picture1.Line (50 + 400 * l, 5500 - (k - 1) * 400)-(50 + 400 * l, 5500 - k * 400) Else Picture1.Line (50 + 400 * l, 50 + (k - 1) * 400)-(50 + 400 * l, 50 + k * 400) End If Else If Ye 0 Then Picture1.Line (5500 - 400 * l, 5500 - (k - 1
12、) * 400)-(5500 - 400 * l, 5500 - k * 400) Else Picture1.Line (5500 - 400 * l, 50 + (k - 1) * 400)-(5500 - 400 * l, 50 + k * 400) End If End If F(m) = F(m - 1) + Int(Abs(Text3) List1.AddItem 第 & m & 步 & y F( & m & )= & F(m) & & x=- & l & & y=- & k & = & j - n End IfNext nEnd SubPrivate Sub Command3_Click()清除 Text3 = : Text4 = : Form1.Cls: Picture1.Cls: Picture2.Cls: List1.ClearEnd SubPrivate Sub Command4_Click()结束 End