求助vb打开txt第一次不显示问题
这是个保存页面,我是先关闭已有的txt窗口,然后把自己listview保存到txt,保存后打开txt,但是问题来了,第一执行保存时候txt出现,然后一闪遍消失了,关闭了,不停留在屏幕上。但是第二次以后运行就正常了,txt打开后会页面不会关闭
Open Dir1.Path & "\" & wenjianming.Text For Output As #1
Dim hang As Integer
Dim lie1 As Double
Dim lie2 As Double
Dim lie3 As Double
Dim lie4 As Double
Shell ("cmd /c taskkill/f /im notepad.exe")
For hang = 1 To ListView2.ListItems.Count
lie1 = ListView2.ListItems(hang).Text
lie2 = ListView2.ListItems(hang).ListSubItems(1)
lie3 = ListView2.ListItems(hang).ListSubItems(2)
Print #1, Format(lie1, "0.000"); " "; Format(lie2, "0.000"); " "; Format(lie3, "0.000")
Next
Close #1
Shell "explorer.exe " & Dir1.Path & "\" & wenjianming.Text, vbMaximizedFocus
[解决办法]
试试:
Private Declare Function ShellExecute _
Lib "shell32.dll" Alias "ShellExecuteA" _
( _
ByVal hwnd As Long, _
ByVal lpOperation As String, _
ByVal lpFile As String, _
ByVal lpParameters As String, _
ByVal lpDirectory As String, _
ByVal nShowCmd As Long _
) As Long
ShellExecute Me.hwnd, "open", Dir1.Path & "\" & wenjianming.Text, "", "", 1
[解决办法]
最大化:
ShellExecute Me.hwnd, "open", Dir1.Path & "\" & wenjianming.Text, "", "", 3
[解决办法]
Shell "NotePad " & Dir1.Path & "\" & wenjianming.Text, vbNormalFocus