现要求计算从原点到整点(x,y)螺旋折线段的长度。小王根据上述描述设计如下VB程序,请回答下列问题:
Dim x As Integer, y As Integer 'x用于存储横坐标的值,y用于存储纵坐标的值
Private Sub Command1_Click()
Dim sum As Integer, m As Integer
Dim dx As Integer, dy As Integer
Dim i As Integer, t As Integer
x=Val(Text1. Text)
y =Val(Text2. Text)
dx = 0:dy=0
sum=0
m=1:t=-1
Do While not check(dx,dy)
For i=1 To m
If check(dx,dy)Then exit do 'Exit do表示退出Do循环
dx = dx+t
sum = sum+1
Next i
For i=1 To m
If check(dx,dy) Then Exit Do
sum = sum + 1
Next i
m=m+1
Loop
Label1. Caption= Str(sum)
End sub
Function check(xl As Integer,y1 As Integer)As Boolean
check = False
If x1=x And y1=y Then
End If
End function