重庆分公司,新征程启航
为企业提供网站建设、域名注册、服务器等服务
Public Class Form1
西峰网站制作公司哪家好,找创新互联!从网页设计、网站建设、微信开发、APP开发、成都响应式网站建设公司等网站项目制作,到程序开发,运营维护。创新互联自2013年起到现在10年的时间,我们拥有了丰富的建站经验和运维经验,来保证我们的工作的顺利进行。专注于网站建设就选创新互联。
System.Runtime.InteropServices.DllImport("user32.dll") _
Private Shared Function SendMessage(ByVal hWnd As Integer, ByVal Msg As Integer, ByVal wParam As Integer, ByVal lParam As Integer) As Integer
End Function
Const SC_MONITORPOWER As Integer = HF170
Const WM_SYSCOMMAND As Integer = H112
Private Enum MonitorMode As Integer
[ON] = -1
STANBY = 1
OFF = 2
End Enum
Private Sub ChangeMonitorState(ByVal mode As MonitorMode)
SendMessage(-1, WM_SYSCOMMAND, SC_MONITORPOWER, CInt(mode))
End Sub
Private Sub Off()
ChangeMonitorState(MonitorMode.OFF)
End Sub
Private Sub [On]()
ChangeMonitorState(MonitorMode.[ON])
End Sub
Private Sub StandBy()
ChangeMonitorState(MonitorMode.STANBY)
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Off()
End Sub
Private Sub Form1_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles Me.KeyDown
If e.KeyCode = Keys.Escape Then [On]()
End Sub
End Class
按button1按钮关闭显示器,按Esc键打开显示器
在窗体上拉一个Timer控件,enabled设为true,Interval设为20。完整代码如下: Dim myPen As New System.Drawing.Pen(System.Drawing.Color.Red)
Dim formGraphics As System.Drawing.Graphics
Dim num As Integer = 1
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
Me.Refresh() '清屏
formGraphics = Me.CreateGraphics()
formGraphics.DrawEllipse(myPen, New Rectangle(100, 100, num, num)) '在坐标(100,100)的位置画圆
If num 200 Then '如果大于200则停止画圆
myPen.Dispose()
formGraphics.Dispose()
Timer1.Enabled = False
Else
num = num + 1
End If
End Sub
这个问题我以前也遇到过,好像是显卡或显卡的驱动问题,在更换显卡(比较好一点的显卡)后问题解决了。
Dim s1!, s2!, a$ '为小数点的叠加,s1,s2必须定义为单精度型
Dim flag As Boolean 'flag它是过程及的变量,在通用里必须声明
'在数字按钮控件单击数组单击事件中获取操作数(没有区分是哪一个操作数)
Private Sub Command1_Click(Index As Integer)
x = Text1.Text
If flag = True Or x = "0" Then '查看数字是否输入完毕或者是否清零了
Text1.Text = CStr(Index) 'CStr将数值转换字符
Else
Text1.Text = Text1.Text + CStr(Index) '"+"在这里这个是对字符串的操作的叠加,CStr(Index)是接的数据
End If
flag = False '时刻准备数字的输入
End Sub
'2.单击运算符,确定s1,并且要选定运算
Private Sub Command2_Click(Index As Integer)
flag = True
s1 = Val(Text1.Text)
Select Case Index
Case 0
a = "+"
Case 1
a = "-"
Case 2
a = "*"
Case 3
a = "/"
End Select
End Sub
'3."="的单击事件
Private Sub Command3_Click()
flag = True
s2 = Val(Text1.Text)
Select Case a
Case "+"
Text1.Text = s1 + s2
Case "-"
Text1.Text = s1 - s2
Case "*"
Text1.Text = s1 * s2
Case "/"
Text1.Text = s1 / s2 '分母不能为0
End Select
s1 = 0: s2 = 0: a = ""
End Sub
'4.清屏
Private Sub Command4_Click()
Text1.Text = "0"
s1 = 0
s2 = 0
a = ""
flag = False
End Sub
'5.删除最后输入的一个字符,换句话说,将本文框中的字符串取字符(从左往右取left(string,length)),将最后一个字符不取就先行
Private Sub Command5_Click()
If Text1.Text = "" Then
Else
Command5.Enabled = True
Text1.Text = Left(Text1.Text, Len(Text1.Text) - 1)
'len求字符串的长度,left(text1.len(text1)-1减1是取字符串从左往右减去一个字符串
End If
End Sub
'小数点 1)显示出"."(注意前面输入过的整数必须显示) 2)小数后能继续接受数字的输入
Private Sub Command6_Click()
Text1 = Text1 "."
End Sub
'7加入正负号--单击“+、-”,产生一个"-",而且处于一种等待数字输入的一种状态
Private Sub Command7_Click()
Dim temp As Double
temp = -Val(Text1.Text)
Text1.Text = temp
If d = " " Then s1 = temp Else s2 = temp
End Sub
Private Sub Command8_Click() '退出
End
End Sub
Private Sub Form_Load() '窗体初始化
Text1.Text = 0
Text1.Locked = True
End Sub
你是怎么绘图的?图形方法都安排到了Graphics对象了,里面有个好象是Clear,不过要什么传递一个颜色参数,其实就是填充颜色。
图形对象在Paint事件的e参数中有,窗体CreateGraphics方法也可以创建Graphics对象。
你应当先关闭文档流:
Me.WebBrowser1.Document.Close()
然后再执行清空:
Me.WebBrowser1.Navigate("about:blank")