vb.net按钮按下,vb 按钮
vb.net 按下按钮1逐行写入程序路径下的文本C分成五行,分别是1、2、3、4、5。
Using Reader As StreamReader = New StreamReader(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "文本.txt"), Encoding.Default)
创新互联公司技术团队10年来致力于为客户提供成都网站建设、网站建设、高端网站设计、成都营销网站建设、搜索引擎SEO优化等服务。经过多年发展,公司拥有经验丰富的技术团队,先后服务、推广了1000+网站,包括各类中小企业、企事单位、高校等机构单位。
Dim a, b, c, d, f As String
a = Reader.ReadLine
b = Reader.ReadLine
c = Reader.ReadLine
d = Reader.ReadLine
f = Reader.ReadLine
End Using
vb.net 怎么知道按下了多个按键
用API GetKeyboardState ,判断所有的键里哪些被按下了。
下面的是判断键盘灯的状态
Public Class NativeMethods
Private Shared keyState() As Byte
DllImport("user32.dll") _
Private Shared Function GetKeyboardState(ByVal keyState() As Byte) As Boolean
End Function
Private Shared Sub Update()
keyState = New Byte(256) {}
Dim result As Boolean = GetKeyboardState(keyState)
' Check for error:
If result = False Then
Debug.WriteLine("GetKeyBoardState error: " Marshal.GetLastWin32Error)
Throw New Exception("GetKeyBoardState error: " Marshal.GetLastWin32Error)
End If
End Sub
Public Enum LightState
Off
[On]
End Enum
' Example - the keyboard lights...
Public Shared ReadOnly Property CapsLockState() As LightState
Get
Update()
Dim isOn As Boolean = (keyState(Keys.CapsLock) = 1)
Return IIf(isOn, LightState.On, LightState.Off)
End Get
End Property
Public Shared ReadOnly Property NumLockState() As LightState
Get
Update()
Dim isOn As Boolean = (keyState(Keys.NumLock) = 1)
Return IIf(isOn, LightState.On, LightState.Off)
End Get
End Property
Public Shared ReadOnly Property ScrollLockState() As LightState
Get
Update()
Dim isOn As Boolean = (keyState(Keys.Scroll) = 1)
Return IIf(isOn, LightState.On, LightState.Off)
End Get
End Property
End Class
大家好!VB.net VS2010,如何捕捉任意按钮的按下事件?
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
For Each Item As Control In Controls
If TypeOf Item Is Button Then
AddHandler Item.Click, AddressOf Buts
End If
Next
End Sub
Sub Buts(ByVal sender As System.Object, ByVal e As System.EventArgs)
AllE_D(False)
Timer1.Interval = 60000
Timer1.Enabled = True
End Sub
Sub AllE_D(ByVal e_d As Boolean)
For Each Item As Control In Controls
Item.Enabled = e_d
Next
End Sub
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
Timer1.Enabled = False
AllE_D(True)
End Sub
vb.net中,如何通过键盘上的按键触发button _click事件
1、将窗口的KeyPreview属性设置为True
Me.KeyPreview = True
2、处理窗口的KeyDown事件
Sub MainFormKeyDown(sender As Object, e As KeyEventArgs)
Select Case e.KeyCode
Case Keys.Escape
Me.button1.PerformClick
Case Keys.Enter
Me.button2.PerformClick
End Select
End Sub
VB.NET按下一个按钮如何弹出第三个窗口,隐藏第一个和第二个
首先要添加两个窗体,假设第一个窗体名为Form1,第二个窗体名为Form2。在Form1窗体中添加个按钮Command1。按钮单击事件的代码为:
Private Sub Command1_Click()
Form2.Show '用show方法加载并且显示名为Form2的窗体
End Sub
show 方法后面省略了两个参数即Form2.Show 0或Form2.Show 1此参数可缺省。可自行运行验证
vb.net的,按键连续触发事件,比如,按着键不放,音量增大。
1.定义变量记录键是否被按下,按下的累计时间
Dim 按下A键 As Boolean
Dim 按下A键时间 As Integer
2.添加一个TextBox1用于接收键盘事件,或者直接用窗体的键盘事件(确保KeyPreview为True)
在KeyDown事件中添加如下代码:
If e.Keycode = keys.A Then 按下A键 = True
在KeyUp事件中添加如下代码:
If e.Keycode = keys.A Then 按下A键 = False
3.添加一个Timer1控件,调整Timer1的Interval来决定按键频率,记得要把Timer1.Enable开启
在Tick事件中添加如下代码:
If 按下A键 = True
按下A键时间+=1
Call 音量设置(按下A键时间 * 10)
End If
PS: 按下的秒数 = 按下A键时间*Timer1.Interval / 1000
当前标题:vb.net按钮按下,vb 按钮
文章位置:http://azwzsj.com/article/dsipogc.html