扫二维码与项目经理沟通
我们在微信上24小时期待你的声音
解答本文疑问/技术咨询/运营咨询/技术建议/互联网交流
楼上的按了一次A+W后,接下来单按W键就会弹出信息框
站在用户的角度思考问题,与客户深入沟通,找到金寨网站设计与金寨网站推广的解决方案,凭借多年的经验,让设计与互联网技术结合,创造个性化、用户体验好的作品,建站类型包括:成都网站制作、成都网站设计、外贸营销网站建设、企业官网、英文网站、手机端网站、网站推广、域名注册、网络空间、企业邮箱。业务覆盖金寨地区。
Public Class Form1
Private Declare Function GetAsyncKeyState Lib "user32.dll" (ByVal keyCode As Integer) As Short
Private Sub Form1_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles Me.KeyDown
If GetAsyncKeyState(Keys.A) And GetAsyncKeyState(Keys.W) Then
MsgBox("你按下了A+W键")
End If
End Sub
End Class
按照顺序的话,这样写:
Public Class Form1
Private Declare Function GetAsyncKeyState Lib "user32.dll" (ByVal keyCode As Integer) As Short
Private Sub Form1_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles Me.KeyDown
If GetAsyncKeyState(Keys.A) And e.KeyCode = Keys.W Then
MsgBox("你按下了A+W键")
End If
End Sub
End Class
望采纳~
你在第一个窗口里写 Form2.ShowDialog()
这样就可以了,关掉form2的时候form1的代码就会继续执行
可以利用msgbox 实现,也可以通过另外的窗体上画出表格实现
方法一,利用msgbox:
Private Sub Command1_Click()Dim a As Long, b As Long, c As LongMsgBox "┌────┬────┬────┐" vbCrLf _ "│ 库存1 │ 库存2 │ 库存3 │" vbCrLf _ "├────┼────┼────┤" vbCrLf _ "│" formatstr(a) "│" formatstr(b) "│" formatstr(c) "│" vbCrLf _ "└────┴────┴────┘" End SubPrivate Function formatstr(ByVal inputStr As String) As StringDim j As Integerj = (8 - Len(inputStr)) \ 2formatstr = Space(j) inputStr Space(j) Space((8 - Len(inputStr)) Mod 2)End Function
方法二,利用窗体实现:
’新建form2窗体‘将以下代码复制到form2窗体中Private Sub Form_Load()ShowPrint "┌────┬────┬────┐" vbCrLf _ "│ 库存1 │ 库存2 │ 库存3 │" vbCrLf _ "├────┼────┼────┤" vbCrLf _ "│" formatstr(a) "│" formatstr(b) "│" formatstr(c) "│" vbCrLf _ "└────┴────┴────┘" End SubPrivate Function formatstr(ByVal inputStr As String) As StringDim j As Integerj = (8 - Len(inputStr)) \ 2formatstr = Space(j) inputStr Space(j) Space((8 - Len(inputStr)) Mod 2)End Function‘将以下代码复制在form1窗体中Private Sub Command1_Click()Form2.ShowEnd Sub
我们在微信上24小时期待你的声音
解答本文疑问/技术咨询/运营咨询/技术建议/互联网交流