VB编程,输入平面上任一点的坐标(x,y),判断并显示该点位于哪个象限的信息
2个回答
展开全部
Dim InX as long ,InY as long
InX = val(inputbox("请输入X轴数值"))
InY = val(inputbox("请输入Y轴数值"))
if InX>0 then
if InY>0 then 'X,Y >0 第一象限
msgbox "坐标(" & inx & "," & Iny & ") 在第一象限"
elseif InY<0 then ' X> 0 >Y第四象限
msgbox "坐标(" & inx & "," & Iny & ") 在第四象限"
end if
elseif InX<0 then
if InY>0 then 'Y>0>X 第二象限
msgbox "坐标(" & inx & "," & Iny & ") 在第二象限"
elseif InY<0 then ' X<Y<0 第三象限
msgbox "坐标(" & inx & "," & Iny & ") 在第三象限"
end if
elseif InX=0 then
if InY=0 then
msgbox "坐标在原点"
elseif InY <>0 then
msgbox "坐标在X轴上"
end if
end if
if InY=0 then
if InX<>0 then
msgbox "坐标在Y轴上"
end if
end if
'懒得开VB了
InX = val(inputbox("请输入X轴数值"))
InY = val(inputbox("请输入Y轴数值"))
if InX>0 then
if InY>0 then 'X,Y >0 第一象限
msgbox "坐标(" & inx & "," & Iny & ") 在第一象限"
elseif InY<0 then ' X> 0 >Y第四象限
msgbox "坐标(" & inx & "," & Iny & ") 在第四象限"
end if
elseif InX<0 then
if InY>0 then 'Y>0>X 第二象限
msgbox "坐标(" & inx & "," & Iny & ") 在第二象限"
elseif InY<0 then ' X<Y<0 第三象限
msgbox "坐标(" & inx & "," & Iny & ") 在第三象限"
end if
elseif InX=0 then
if InY=0 then
msgbox "坐标在原点"
elseif InY <>0 then
msgbox "坐标在X轴上"
end if
end if
if InY=0 then
if InX<>0 then
msgbox "坐标在Y轴上"
end if
end if
'懒得开VB了
展开全部
Function which(ByVal p As PointF) As String
Dim tp As String = Math.Sign(p.X) & "," & Math.Sign(p.Y)
Select Case tp
Case "0,0"
Return "原点"
Case "0,1", "0,-1"
Return "y轴"
Case "1,0", "-1,0"
Return "x轴"
Case "1,1"
Return "第一象限"
Case "-1,1"
Return "第二象限"
Case "-1,-1"
Return "第三象限"
Case "1,-1"
Return "第四象限"
End Select
End Function
Dim tp As String = Math.Sign(p.X) & "," & Math.Sign(p.Y)
Select Case tp
Case "0,0"
Return "原点"
Case "0,1", "0,-1"
Return "y轴"
Case "1,0", "-1,0"
Return "x轴"
Case "1,1"
Return "第一象限"
Case "-1,1"
Return "第二象限"
Case "-1,-1"
Return "第三象限"
Case "1,-1"
Return "第四象限"
End Select
End Function
本回答被提问者和网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询