
有关VB做的画图程序的一些问题
在网上看到这段代码本人新手希望大家能把这段代码每句话的意思告诉我我有好多看不懂。。DimiAsBooleanPrivateSubForm_MouseDown(Button...
在网上看到这段代码 本人新手 希望大家能把这段代码每句话的意思告诉我 我有好多看不懂。。
Dim i As Boolean
Private Sub Form_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
i = True
End Sub
Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Not i Then
Me.CurrentX = X
Me.CurrentY = Y
Else
Me.Line -(X, Y)
End If
End Sub
Private Sub Form_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
i = False
End Sub
另外哦~ 我在VB上 把这段代码输入进去 。运行是ok的 不过我想把它分成2部分。上面是画图的 下面我想设置2个按钮 一个可以清除画的东西 一个是 关闭程序 。 大家能说说怎么操作吗?
画上去的线条粗细能不能改变的啊? 该怎么操作 展开
Dim i As Boolean
Private Sub Form_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
i = True
End Sub
Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Not i Then
Me.CurrentX = X
Me.CurrentY = Y
Else
Me.Line -(X, Y)
End If
End Sub
Private Sub Form_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
i = False
End Sub
另外哦~ 我在VB上 把这段代码输入进去 。运行是ok的 不过我想把它分成2部分。上面是画图的 下面我想设置2个按钮 一个可以清除画的东西 一个是 关闭程序 。 大家能说说怎么操作吗?
画上去的线条粗细能不能改变的啊? 该怎么操作 展开
4个回答
展开全部
都是很简单的
Private Sub Form_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
i = True
End Sub
//鼠标按下时 把true赋给i
//当鼠标移动时
(然后内部函数内部)--当非i(i就是上面的取值,i= true时 not i就是false)时
把鼠标的当前X,Y坐标坐标赋给默认的输出位置坐标
否则(否则条件就是当not i = false时)
画一个坐标是-(x,y)的点
Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Not i Then
Me.CurrentX = X
Me.CurrentY = Y
Else
Me.Line -(X, Y)
End If
End Sub
Private Sub Form_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
i = False
End Sub
//当鼠标弹起时,把false赋给i
至于清屏和结束程序就更简单了
在按扭处添加代码
form1.cls
和
end
上面一条是清屏,下面一条是结束程序
form1是窗体名喔
=============================
改变粗细的话,用line的DrawWidth属性就可以了喔~~
Private Sub Form_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
i = True
End Sub
//鼠标按下时 把true赋给i
//当鼠标移动时
(然后内部函数内部)--当非i(i就是上面的取值,i= true时 not i就是false)时
把鼠标的当前X,Y坐标坐标赋给默认的输出位置坐标
否则(否则条件就是当not i = false时)
画一个坐标是-(x,y)的点
Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Not i Then
Me.CurrentX = X
Me.CurrentY = Y
Else
Me.Line -(X, Y)
End If
End Sub
Private Sub Form_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
i = False
End Sub
//当鼠标弹起时,把false赋给i
至于清屏和结束程序就更简单了
在按扭处添加代码
form1.cls
和
end
上面一条是清屏,下面一条是结束程序
form1是窗体名喔
=============================
改变粗细的话,用line的DrawWidth属性就可以了喔~~
更多追问追答
追问
方便留下您的qq号吗? 以后我有什么不懂得地方 来请教你您
追答
我暂时不在大陆.有阵子也不会回去,登陆扣扣需要挂代理很麻烦,有需要可以用百度直接跟我说,我百度经常在线的或者用邮箱visonshadowtevet@sina.com
展开全部
Private Sub Command1_Click()
Me.Cls
End Sub
Private Sub Command2_Click()
Unload Me
End Sub
Private Sub Form_Load()
Me.Command1.Caption = "清除"
Me.Command2.Caption = "退出"
End Sub
Me.Cls
End Sub
Private Sub Command2_Click()
Unload Me
End Sub
Private Sub Form_Load()
Me.Command1.Caption = "清除"
Me.Command2.Caption = "退出"
End Sub
追问
Me.Cls和
Unload Me
是什么意思啊? 根据我提供的代码 似乎是在整个窗体上都可以画的 而我是打算让它分开 。就比如说是上面是可以画的 然后分开 下面是这两个按钮 这个应该怎么弄呢
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
me.cls的意思是清楚当前窗体上由line,pset,circle等方法画出的图形,unload me是卸载窗体,就是结束你的程序。至于你想要的操作可以这样,
private sub command1_click() '清除图形
me.cls
end sub
private sub command2_click() '退出程序
end
end sub
mousedown、mousemove、mouseup是很常见的鼠标操作事件,很有用,呵呵
private sub command1_click() '清除图形
me.cls
end sub
private sub command2_click() '退出程序
end
end sub
mousedown、mousemove、mouseup是很常见的鼠标操作事件,很有用,呵呵
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
这个程序看着很眼熟,嘿嘿
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询