十年网站开发经验 + 多家企业客户 + 靠谱的建站团队
量身定制 + 运营维护+专业推广+无忧售后,网站问题一站解决
可以利用msgbox 实现,也可以通过另外的窗体上画出表格实现
创新互联建站专业提供西信服务器托管服务,为用户提供五星数据中心、电信、双线接入解决方案,用户可自行在线购买西信服务器托管服务,并享受7*24小时金牌售后服务。
方法一,利用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
楼上的按了一次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的代码就会继续执行