以文本方式查看主题

-  Foxtable(狐表)  (http://www.foxtable.com/bbs/index.asp)
--  专家坐堂  (http://www.foxtable.com/bbs/list.asp?boardid=2)
----  [求助]打开外部文件代码  (http://www.foxtable.com/bbs/dispbbs.asp?boardid=2&id=84711)

--  作者:wusim
--  发布时间:2016/5/8 17:52:00
--  [求助]打开外部文件代码
Dim f As String = rojectPath & "合格证\\" & 出厂编号查找 &  ".*"
If FileSys.FileExists(f) Then
    Dim Proc As New Process \'定义一个新的Process
    Proc.File = f \'指定要打开的文件
    Proc.Start()
Else
    msgbox("不存在")
End If

我想在文本框中输入出厂编号,就能打开与输入编号相同的文件。 怎样改代码?

--  作者:wusim
--  发布时间:2016/5/8 21:47:00
--  
已解决 
Dim f As String = ProjectPath & "合格证\\" & Tables("基本信息表").Current("出厂编号") &  ".doc"
If FileSys.FileExists(f) Then
    Dim Proc As New Process \'定义一个新的Process
    Proc.File = f \'指定要打开的文件
    Proc.Start()
Else
    msgbox("文件不存在")
End If

如果不确定是cls文件还是doc文件

--  作者:大红袍
--  发布时间:2016/5/9 9:20:00
--  
Dim f As String = ProjectPath & "合格证\\" & Tables("基本信息表").Current("出厂编号") &  ".*"
Dim exist As Boolean = False
For Each fname As String In filesys.GetFiles(FileSys.GetParentPath(f))
    If fname Like f Then
        exist = True
        Dim Proc As New Process \'定义一个新的Process
        Proc.File = f \'指定要打开的文件
        Proc.Start()
        Exit For
    End If
Next
If exist = False Then
    msgbox("文件不存在")
End If