VB中的窗体名称是通过选择或输入得到的。那么如何使用Show调用呢?请教了。
来源:百度知道 编辑:UC知道 时间:2024/06/24 13:12:47
这个主窗体可以调用任何一个其他窗体。
Private Sub Form_Load()'''要先Load所有窗体
Load Form1
Load Form2
……
End Sub
Private Sub Command1_Click()
Dim f1 As Form
For Each f1 In VB.Forms
If f1.Name = "Form2" Then f1.Show
Next
End Sub
'在窗体代码区复制下面代码,运行后输入窗口标题,即可显示该窗口
'====窗体代码区====
Option Explicit
Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Private Declare Function ShowWindow Lib "user32" (ByVal hwnd As Long, ByVal nCmdShow As Long) As Long
Const SW_SHOWNORMAL = 1
Const WM_CLOSE = &H10
Private Sub Form_Load()
Dim WinWnd As Long, Ret As String, RetVal As Long, lpClassName As String
Ret = InputBox("请输入窗口标题:")
WinWnd = FindWindow(vbNullString, Ret)
If WinWnd = 0 Then MsgBox "标题输入不正确,窗口找不到!": Ex