在界面添加二个Line控件,一个Label控件,二个text控件,一个Command即可,代码如下:
Private Sub Command1_Click()
If Text1.Text = "" Then
MsgBox "X坐标不能空!", 16, "错误!"
Exit Sub
End If
If Text2.Text = "" Then
MsgBox "Y坐标不能空!", 16, "错误!"
Exit Sub
End If
Dim X As Single, Y As Single
X = Val(Text1.Text)
Y = Val(Text2.Text)
Label1.Left = X - 50
Label1.Top = Y - 50
If X > Me.Width / 2 And Y < Me.Height / 2 Then
Text2.Text = "坐标在第一象限!"
Text1.Text = ""
ElseIf X < Me.Width / 2 And Y < Me.Height / 2 Then
Text2.Text = "坐标在第二象限!"
Text1.Text = ""
ElseIf X < Me.Width / 2 And Y > Me.Height / 2 Then
Text2.Text = "坐标在第三象限!"
Text1.Text = ""
ElseIf X > Me.Width / 2 And Y > Me.Height / 2 Then
Text2.Text = "坐标在第四象限!"
Text1.Text = ""
End If
'不能截图,可能是我的系统问题。给QQ我发给你。
End Sub
Private Sub Form_Load()
Line1.BorderWidth = 2
Line1.BorderColor = &H109910
Line1.X1 = 0
Line1.X2 = Me.Width
Line1.Y1 = Me.Height / 2
Line1.Y2 = Me.Height / 2
Line2.BorderWidth = 2
Line2.BorderColor = &H109910
Line2.X1 = Me.Width / 2
Line2.X2 = Me.Width / 2
Line2.Y1 = 0
Line2.Y2 = Me.Height
Label1.Height = 100
Label1.Width = 100
Label1.BackColor = &H1010FF
Label1.Left = Me.Width / 2 - 50
Label1.Top = Me.Height / 2 - 50
'原点坐标:Me.Width / 2,Me.Height / 2
End Sub来自:求助得到的回答
温馨提示:答案为网友推荐,仅供参考