vb的命令按钮要实现点一下向右移一位,再点再移,代码应该怎么写啊
vb的命令按钮要实现点一下向右移一位,再点再移。。。。一直下去。代码应该怎么写啊。急!!刚学的新手,谢谢指教...
vb的命令按钮要实现点一下向右移一位,再点再移。。。。一直下去。代码应该怎么写啊。急!!刚学的新手,谢谢指教
展开
5个回答
展开全部
Private Sub Command1_Click()
Command1.Left = Command1.Left + 300
End Sub
点一下右移300缇(相当于20像素)
Command1.Left = Command1.Left + 300
End Sub
点一下右移300缇(相当于20像素)
本回答被网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
2013-04-13
展开全部
楼上的 写得太复杂了
Private Sub Command1_Click()
Command1.Left = Command1.Left + 100 '这里的100 是指移动的距离如需要向左移则是把+改成-
End Sub
Private Sub Command1_Click()
Command1.Left = Command1.Left + 100 '这里的100 是指移动的距离如需要向左移则是把+改成-
End Sub
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
2013-04-13
展开全部
'添加 Command1(0) 注意是数组,把属性中的Index设为 0
Dim i%, oldx(4) As Integer
Private Sub Form_Load()
Me.Move (Screen.Width - Me.Width) \ 2, (Screen.Height - Me.Height) \ 2
For i = 1 To 4
Load Command1(i)
Command1(i).Visible = True
Command1(i).Caption = "按 钮" & Str(i)
Next i
Command1(0).Caption = "恢 复"
Call plbutton
End Sub
Private Sub Command1_Click(Index As Integer)
Select Case Index
Case 0
Call plbutton
Case Else
Command1(Index).Left = IIf(Command1(Index).Left <> 30, 30, oldx(Index))
End Select
End Sub
Sub plbutton()
Command1(0).Top = 0
For i = 1 To 4
Command1(i).Top = Command1(i - 1).Top + Command1(i).Height + 30
Command1(i).Left = Me.ScaleWidth - Command1(i).Width - 50
oldx(i) = Command1(i).Left
Next i
Command1(0).Left = (Me.ScaleWidth - Command1(0).Width) \ 2
Command1(0).Top = Me.ScaleHeight - 50 - Command1(0).Height
End Sub
你可以参考一下这段代码做一下吧!
Dim i%, oldx(4) As Integer
Private Sub Form_Load()
Me.Move (Screen.Width - Me.Width) \ 2, (Screen.Height - Me.Height) \ 2
For i = 1 To 4
Load Command1(i)
Command1(i).Visible = True
Command1(i).Caption = "按 钮" & Str(i)
Next i
Command1(0).Caption = "恢 复"
Call plbutton
End Sub
Private Sub Command1_Click(Index As Integer)
Select Case Index
Case 0
Call plbutton
Case Else
Command1(Index).Left = IIf(Command1(Index).Left <> 30, 30, oldx(Index))
End Select
End Sub
Sub plbutton()
Command1(0).Top = 0
For i = 1 To 4
Command1(i).Top = Command1(i - 1).Top + Command1(i).Height + 30
Command1(i).Left = Me.ScaleWidth - Command1(i).Width - 50
oldx(i) = Command1(i).Left
Next i
Command1(0).Left = (Me.ScaleWidth - Command1(0).Width) \ 2
Command1(0).Top = Me.ScaleHeight - 50 - Command1(0).Height
End Sub
你可以参考一下这段代码做一下吧!
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
Private Sub Command1_Click()
On Error Resume Next
Command1.Left = Command1.Left + 100
End Sub
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询