VB做一个标签 四个控件 点上向上移动 点左向左 15
3个回答
展开全部
在窗体上放四个命令按钮,command1(上)command2(左)command3(下)command4(右)和一个标签label1。
把代码复制到窗体里即可。程序运行时单击相应的近似,标签控件向那个方向移动。
代码如下:
Private Sub Command1_Click()
Label1.Top = Label1.Top - 50
End Sub
Private Sub Command2_Click()
Label1.Left = Label1.Left - 50
End Sub
Private Sub Command3_Click()
Label1.Top = Label1.Top + 50
End Sub
Private Sub Command4_Click()
Label1.Left = Label1.Left + 50
End Sub
Private Sub Form_Load()
Command1.Caption = "上"
Command2.Caption = "左"
Command3.Caption = "下"
Command4.Caption = "右"
Label1.Caption = "欢迎使用VB"
End Sub
把代码复制到窗体里即可。程序运行时单击相应的近似,标签控件向那个方向移动。
代码如下:
Private Sub Command1_Click()
Label1.Top = Label1.Top - 50
End Sub
Private Sub Command2_Click()
Label1.Left = Label1.Left - 50
End Sub
Private Sub Command3_Click()
Label1.Top = Label1.Top + 50
End Sub
Private Sub Command4_Click()
Label1.Left = Label1.Left + 50
End Sub
Private Sub Form_Load()
Command1.Caption = "上"
Command2.Caption = "左"
Command3.Caption = "下"
Command4.Caption = "右"
Label1.Caption = "欢迎使用VB"
End Sub
展开全部
Private Sub Form_Load()
Command1.Caption = "上"
Command2.Caption = "左"
Command3.Caption = "下"
Command4.Caption = "右"
End Sub
Private Sub Command1_Click()
Command1.Top = Command1.Top - 20
End Sub
Private Sub Command2_Click()
Command2.Left = Command2.Left - 20
End Sub
Command1.Caption = "上"
Command2.Caption = "左"
Command3.Caption = "下"
Command4.Caption = "右"
End Sub
Private Sub Command1_Click()
Command1.Top = Command1.Top - 20
End Sub
Private Sub Command2_Click()
Command2.Left = Command2.Left - 20
End Sub
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
放置1个Command控件,并且复制它,粘贴,点确定生成一控件数组。
总共复制3次,生成4个按钮,按照复制出来的顺序分别标上“上”,“左”,“下”,“右”。
最后放上你的标签。
Private Sub Command1_Click(Index As Integer)
Dim msX As Long, msY As Long
dim PosX as long ,PosY as long
PosX = label1.left
PosY = label1.top
Select Case Index
Case 0 'up
msY = posy - 50
msX = posx
Case 1 'left
msX = PosX - 50
msY = PosY
Case 2 'down
msY = PosY + 50
msX = PosX
Case 3 'right
msX = PosX + 50
msY = PosY
Case Else
Exit Sub
End Select
label1.move msx,msy
End Sub
'--------觉得好多给分,谢谢!
总共复制3次,生成4个按钮,按照复制出来的顺序分别标上“上”,“左”,“下”,“右”。
最后放上你的标签。
Private Sub Command1_Click(Index As Integer)
Dim msX As Long, msY As Long
dim PosX as long ,PosY as long
PosX = label1.left
PosY = label1.top
Select Case Index
Case 0 'up
msY = posy - 50
msX = posx
Case 1 'left
msX = PosX - 50
msY = PosY
Case 2 'down
msY = PosY + 50
msX = PosX
Case 3 'right
msX = PosX + 50
msY = PosY
Case Else
Exit Sub
End Select
label1.move msx,msy
End Sub
'--------觉得好多给分,谢谢!
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询