Results 1 to 2 of 2

Thread: Like to see how other would do this

  1. #1

    Thread Starter
    Hyperactive Member mudfish's Avatar
    Join Date
    Feb 2004
    Location
    Chit Chat
    Posts
    353

    Like to see how other would do this


    VB 6.5

    VB Code:
    1. Private Declare Function ShellExecute Lib "shell32.dll" _
    2.    Alias "ShellExecuteA" _
    3.   (ByVal hwnd As Long, _
    4.    ByVal lpOperation As String, _
    5.    ByVal lpFile As String, _
    6.    ByVal lpParameters As String, _
    7.    ByVal lpDirectory As String, _
    8.    ByVal nShowCmd As Long) As Long
    9.  
    10. Sub Main()
    11.    Const SW_SHOWDEFAULT As Long = 10
    12.    Dim strFullPathToFile As String
    13. ''''''''''''''''''''''''''''''''''\ The name of
    14. '''''Note'''''''''''''''''''''''''\ document goes
    15. ''''''''''''''''''''''''''''''''''\    here
    16.    strFullPathToFile = App.Path & "\SCVR 4C Acknowledgment and Consent.doc"
    17.  
    18.  
    19.    Call ShellExecute(0, "Open", strFullPathToFile _
    20.    , 0&, 0&, SW_SHOWDEFAULT)
    21.  
    22.  
    23.    End
    24.    
    25. End Sub

    How I do it in .Net
    VB Code:
    1. Option Strict Off
    2. Option Explicit On
    3. Module SCVRPrintForm4C
    4.     Dim i As Integer
    5.  
    6.     Private Declare Function ShellExecute Lib "shell32.dll"  Alias "ShellExecuteA"(ByVal hwnd As Integer, ByVal lpOperation As String, ByVal lpFile As String, ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As Integer) As Integer
    7.    
    8.     Public Sub Main()
    9.         Const SW_SHOWDEFAULT As Integer = 10
    10.         Dim strFullPathToFile As String
    11.  
    12.  
    13.         ''''''''''''''''''''''''''''''''''\ The name of
    14.         '''''Note'''''''''''''''''''''''''\ document goes
    15.         ''''''''''''''''''''''''''''''''''\    here
    16.         strFullPathToFile = Application.StartupPath & "\SCVR 4C Acknowledgment and Consent.doc"
    17.        
    18.        
    19.         i = ShellExecute(0, "Open", strFullPathToFile, CStr(0), CStr(0), SW_SHOWDEFAULT)
    20.  
    21.        
    22.        
    23.         End
    24.        
    25.     End Sub
    26. End Module

    I get this line when I use the wizard to convert!

    strFullPathToFile = VB6.GetPath & "\SCVR 4C Acknowledgment and Consent.doc"

    VB6.GetPath
    What is this VB6, some kind of funtion to convert?


    Mudfish AKA Bowfin
    I can spell "If" all day right, just a coder!


    "Always do sober what you said you'd do drunk. That will teach you to keep your mouth shut." -- Ernest Hemingway

    Member of the ECCC

  2. #2
    Fanatic Member pax's Avatar
    Join Date
    Mar 2001
    Location
    Denmark
    Posts
    840
    Hi.

    I think you'd be better of using the Process class.

    VB Code:
    1. Process.Start(Io.Path.Combine(Application.StartUpPath,"SCVR 4C Acknowledgment and Consent.doc"))

    The Application.StartUpPath is the path to your BIN directory.

    The VB6 namespace is, as far as I know, only for compatability.
    I wish I could think of something witty to put in my sig...

    ...Currently using VS2013...

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width