VB多个form窗口
本人是个菜鸟。。。。现在想知道,怎样设置,让程序运行后显示Form1,再已按键形式呼叫出其他窗口...
本人是个菜鸟。。。。
现在想知道,怎样设置,让程序运行后显示Form1,再已按键形式呼叫出其他窗口 展开
现在想知道,怎样设置,让程序运行后显示Form1,再已按键形式呼叫出其他窗口 展开
展开全部
在Form1的KeyDown,KeyPress,KeyUp事件的响应函数里,检测按键
下面是一个例子:
Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
'If KeyCode = vbKey2 Then Form2.Show Else Form3.Show
End Sub
Private Sub Form_KeyPress(KeyAscii As Integer)
Dim mychar As Byte
'mychar = Chr(KeyAscii)
'If mychar = "2" Then Form2.Show Else Form3.Show
End Sub
Private Sub Form_KeyUp(KeyCode As Integer, Shift As Integer)
If KeyCode = vbKey2 And Shift = 1 Then Form2.Show Else Form3.Show
End Sub
下面是VB的帮助KeyDown事件示例代码
打开一个新的工程并将变量 ShiftKey 添加到窗体的声明部分中:
Dim ShiftKey as Integer
将 Textbox 控件添加到窗体上并将此过程添加到 KeyDown 事件中:Private Sub Text1_KeyDown(KeyCode As Integer, _
Shift As Integer)
ShiftKey = Shift And 7
Select Case ShiftKey
Case 1 '或 vbShiftMask Print "You pressed the SHIFT key." Case 2 '或 vbCtrlMask Print "You pressed the CTRL key." Case 4 '或 vbAltMask Print "You pressed the ALT key." Case 3 Print "You pressed both SHIFT and CTRL." Case 5 Print "You pressed both SHIFT and ALT." Case 6 Print "You pressed both CTRL and ALT." Case 7 Print "You pressed SHIFT, CTRL, and ALT." End SelectEnd Sub
下面是一个例子:
Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
'If KeyCode = vbKey2 Then Form2.Show Else Form3.Show
End Sub
Private Sub Form_KeyPress(KeyAscii As Integer)
Dim mychar As Byte
'mychar = Chr(KeyAscii)
'If mychar = "2" Then Form2.Show Else Form3.Show
End Sub
Private Sub Form_KeyUp(KeyCode As Integer, Shift As Integer)
If KeyCode = vbKey2 And Shift = 1 Then Form2.Show Else Form3.Show
End Sub
下面是VB的帮助KeyDown事件示例代码
打开一个新的工程并将变量 ShiftKey 添加到窗体的声明部分中:
Dim ShiftKey as Integer
将 Textbox 控件添加到窗体上并将此过程添加到 KeyDown 事件中:Private Sub Text1_KeyDown(KeyCode As Integer, _
Shift As Integer)
ShiftKey = Shift And 7
Select Case ShiftKey
Case 1 '或 vbShiftMask Print "You pressed the SHIFT key." Case 2 '或 vbCtrlMask Print "You pressed the CTRL key." Case 4 '或 vbAltMask Print "You pressed the ALT key." Case 3 Print "You pressed both SHIFT and CTRL." Case 5 Print "You pressed both SHIFT and ALT." Case 6 Print "You pressed both CTRL and ALT." Case 7 Print "You pressed SHIFT, CTRL, and ALT." End SelectEnd Sub
追问
没太看懂啊。。。
我只是想设置,执行程序后直接显示Form1,而不会一启动程序后显示Form2。
追答
1) 设置属性,只要不是英文版,VB不需要汉化,有真正的中文版
英文版也没问题
属性 英文应该是 Attribute 或者Property,前面应该会有 Project1's 之类的东西.
Start Object
Sub Main
Form1
选择 Form1
或者
key.bas 里写以下代码 就可以了!
sub main
form1.show
end sub
展开全部
对按钮编程, form2.show 就是显示form2
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询