初学VB遇到的一个程序设计题
最近正在自学VB,遇到一个编程题,题目是这样的:当用户单击窗体时,在标题栏显示“鼠标单击窗体”,在窗体显示“您好,欢迎使用VB”当用户双击窗体时,在标题栏显示“鼠标双击窗...
最近正在自学VB,遇到一个编程题,题目是这样的:
当用户单击窗体时,在标题栏显示“鼠标单击窗体”,在窗体显示“您好,欢迎使用VB”当用户双击窗体时,在标题栏显示“鼠标双击窗体”,在窗体显示“再见,谢谢使用VB”。
希望有知道的大侠们指点小弟一下,最好能把程序设计的过程写出来。
(希望大家别见笑,小弟没有任何编程经验)
我设计的程序是这样的:Private Sub Form_Click()
Form1.FontSize = 20
Form1.FontName = "黑体"
Form1.ForeColor = RGB(255, 0, 0)
Form1.Print "你好,欢迎使用VB"
Form1.Caption = 鼠标单击窗体
End Sub
Private Sub Form_DblClick()
Form1.FontSize = 20
Form1.FontName = "黑体"
Form1.ForeColor = RGB(255, 0, 0)
Form1.Print "再见,谢谢使用VB"
Form1.Caption = 鼠标双击窗体
End Sub
我运行这程序的时候标题栏显示不出来,而且双击的时候老是先触发单击事件 展开
当用户单击窗体时,在标题栏显示“鼠标单击窗体”,在窗体显示“您好,欢迎使用VB”当用户双击窗体时,在标题栏显示“鼠标双击窗体”,在窗体显示“再见,谢谢使用VB”。
希望有知道的大侠们指点小弟一下,最好能把程序设计的过程写出来。
(希望大家别见笑,小弟没有任何编程经验)
我设计的程序是这样的:Private Sub Form_Click()
Form1.FontSize = 20
Form1.FontName = "黑体"
Form1.ForeColor = RGB(255, 0, 0)
Form1.Print "你好,欢迎使用VB"
Form1.Caption = 鼠标单击窗体
End Sub
Private Sub Form_DblClick()
Form1.FontSize = 20
Form1.FontName = "黑体"
Form1.ForeColor = RGB(255, 0, 0)
Form1.Print "再见,谢谢使用VB"
Form1.Caption = 鼠标双击窗体
End Sub
我运行这程序的时候标题栏显示不出来,而且双击的时候老是先触发单击事件 展开
9个回答
展开全部
Form1.FontSize = 20
Form1.FontName = "黑体"
Form1.ForeColor = RGB(255, 0, 0)
Form1.Print "你好,欢迎使用VB"
Form1.Caption = "鼠标单击窗体"
End Sub
Private Sub Form_DblClick()
Form1.FontSize = 20
Form1.FontName = "黑体"
Form1.ForeColor = RGB(255, 0, 0)
Form1.Print "再见,谢谢使用VB"
Form1.Caption = "鼠标双击窗体"
End Sub
vba /excel中试了挺好呀,如下(有的属性不一样加了‘):
Private Sub UserForm_Click()
'UserForm.FontSize = 20
'UserForm.FontName = "黑体"
UserForm.ForeColor = RGB(255, 0, 0)
'UserForm.Print "你好,欢迎使用VB"
UserForm.Caption = "鼠标单击窗体"
End Sub
Private Sub UserForm_DblClick(ByVal Cancel As MSForms.ReturnBoolean)
'UserForm.FontSize = 20
'UserForm.FontName = "黑体"
UserForm.ForeColor = RGB(255, 0, 0)
'UserForm.Print "再见,谢谢使用VB"
UserForm.Caption = "鼠标双击窗体"
End Sub
Form1.FontName = "黑体"
Form1.ForeColor = RGB(255, 0, 0)
Form1.Print "你好,欢迎使用VB"
Form1.Caption = "鼠标单击窗体"
End Sub
Private Sub Form_DblClick()
Form1.FontSize = 20
Form1.FontName = "黑体"
Form1.ForeColor = RGB(255, 0, 0)
Form1.Print "再见,谢谢使用VB"
Form1.Caption = "鼠标双击窗体"
End Sub
vba /excel中试了挺好呀,如下(有的属性不一样加了‘):
Private Sub UserForm_Click()
'UserForm.FontSize = 20
'UserForm.FontName = "黑体"
UserForm.ForeColor = RGB(255, 0, 0)
'UserForm.Print "你好,欢迎使用VB"
UserForm.Caption = "鼠标单击窗体"
End Sub
Private Sub UserForm_DblClick(ByVal Cancel As MSForms.ReturnBoolean)
'UserForm.FontSize = 20
'UserForm.FontName = "黑体"
UserForm.ForeColor = RGB(255, 0, 0)
'UserForm.Print "再见,谢谢使用VB"
UserForm.Caption = "鼠标双击窗体"
End Sub
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
Private Sub Form_Click()
cls
Form1.Print "你好,欢迎使用VB"
Form1.Caption = "鼠标单击窗体"
End Sub
Private Sub Form_DblClick()
cls
Form1.Print "再见,谢谢使用VB"
Form1.Caption = "鼠标双击窗体"
End Sub
cls
Form1.Print "你好,欢迎使用VB"
Form1.Caption = "鼠标单击窗体"
End Sub
Private Sub Form_DblClick()
cls
Form1.Print "再见,谢谢使用VB"
Form1.Caption = "鼠标双击窗体"
End Sub
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
Dim isDBc As Boolean
Private Sub Form_Click()
isDBc = False
Timer1.Enabled = True
End Sub
Private Sub Form_DblClick()
isDBc = True
Timer1.Enabled = True
End Sub
Private Sub Form_Load()
Timer1.Interval = 300
Timer1.Enabled = False
End Sub
Private Sub Timer1_Timer()
If isDBc <> True Then
Me.Print "你好,欢迎使用VB"
Me.Caption = "鼠标单击窗体"
Else
Me.Print "再见,谢谢使用VB"
Me.Caption = "鼠标双击窗体"
End If
Timer1.Enabled = False
End Sub
在窗体上添加一个Timer控件
标题栏不显示的原因是你没加双引号
Private Sub Form_Click()
isDBc = False
Timer1.Enabled = True
End Sub
Private Sub Form_DblClick()
isDBc = True
Timer1.Enabled = True
End Sub
Private Sub Form_Load()
Timer1.Interval = 300
Timer1.Enabled = False
End Sub
Private Sub Timer1_Timer()
If isDBc <> True Then
Me.Print "你好,欢迎使用VB"
Me.Caption = "鼠标单击窗体"
Else
Me.Print "再见,谢谢使用VB"
Me.Caption = "鼠标双击窗体"
End If
Timer1.Enabled = False
End Sub
在窗体上添加一个Timer控件
标题栏不显示的原因是你没加双引号
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
Private Sub Form-load()
Caption = ""
Private Sub Form_Click()
Cls
Form1.FontSize = 20
Form1.FontName = "黑体"
Form1.ForeColor = RGB(255, 0, 0)
Form1.Print "你好,欢迎使用VB"
Form1.Caption = "鼠标单击窗体"
End Sub
Private Sub Form_DblClick()
Cls
Form1.FontSize = 20
Form1.FontName = "黑体"
Form1.ForeColor = RGB(255, 0, 0)
Form1.Print "再见,谢谢使用VB"
Form1.Caption = "鼠标双击窗体"
End Sub
Caption = ""
Private Sub Form_Click()
Cls
Form1.FontSize = 20
Form1.FontName = "黑体"
Form1.ForeColor = RGB(255, 0, 0)
Form1.Print "你好,欢迎使用VB"
Form1.Caption = "鼠标单击窗体"
End Sub
Private Sub Form_DblClick()
Cls
Form1.FontSize = 20
Form1.FontName = "黑体"
Form1.ForeColor = RGB(255, 0, 0)
Form1.Print "再见,谢谢使用VB"
Form1.Caption = "鼠标双击窗体"
End Sub
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
Dim isDBc As Boolean
Private Sub Form_Click()
isDBc = False
Timer1.Enabled = True
End Sub
Private Sub Form_DblClick()
isDBc = True
Timer1.Enabled = True
End Sub
Private Sub Form_Load()
Timer1.Interval = 300
Timer1.Enabled = False
End Sub
Private Sub Timer1_Timer()
If isDBc <> True Then
Me.Print "你好,欢迎使用VB"
Me.Caption = "鼠标单击窗体"
Else
Me.Print "再见,谢谢使用VB"
Me.Caption = "鼠标双击窗体"
End If
Timer1.Enabled = False
End Sub
在窗体上添加一个 Timer控件
再粘帖上面的代码就可以了
标题栏不显示的原因是你没加双引号将字符串引住的原因
Private Sub Form_Click()
isDBc = False
Timer1.Enabled = True
End Sub
Private Sub Form_DblClick()
isDBc = True
Timer1.Enabled = True
End Sub
Private Sub Form_Load()
Timer1.Interval = 300
Timer1.Enabled = False
End Sub
Private Sub Timer1_Timer()
If isDBc <> True Then
Me.Print "你好,欢迎使用VB"
Me.Caption = "鼠标单击窗体"
Else
Me.Print "再见,谢谢使用VB"
Me.Caption = "鼠标双击窗体"
End If
Timer1.Enabled = False
End Sub
在窗体上添加一个 Timer控件
再粘帖上面的代码就可以了
标题栏不显示的原因是你没加双引号将字符串引住的原因
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询