DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 10 of 10

Thread: convert VBScript to DLL

  1. #1
    Join Date
    Jul 2008
    Posts
    13

    Question convert VBScript to DLL

    Hello,please could anyone of you tell me as how to convert VBScript to DLL.I am in urgent need of the exact steps.Please do guide.Thanks

    Cheers

  2. #2
    Join Date
    Mar 2008
    Location
    Lancashire, UK
    Posts
    156
    Welcome to DevX

    Try this

    Just copy your code from the script to VB6 and make the Dll.
    If you get any errors, just say

  3. #3
    Join Date
    Jul 2008
    Posts
    13

    Thank you so much

    Thanks a lot.I got the solution.Do you have any other choice to do it?If so please let me know.Will get back to you if any other doubts regarding the same exists.Thanks again.but how to execute my sample.Here is a simple one.i am getting compile error "invalid outside procedure".Please guide me.

    Import mydll

    Private Sub Command1_Click()



    Set fso = CreateObject("Scripting.FileSystemObject")
    fso.CopyFile "c:\mydir\*.*", "d:\backup\", True


    End Sub

    Thnks
    Last edited by pyar123; 07-15-2008 at 03:47 AM.

  4. #4
    Join Date
    Mar 2008
    Location
    Lancashire, UK
    Posts
    156
    Not too sure whether that 'Import mydll' will work.

    Have you added a reference to it in Project > References?

  5. #5
    Join Date
    Apr 2007
    Location
    Sterling Heights, Michigan
    Posts
    8,663
    Imports are what is used in VB.NET, not VB6

    pyar123: Which of the two are you using?

  6. #6
    Join Date
    Jul 2008
    Posts
    13

    Question Convert VBScript to DLL(.NET DLL)

    Thanks. I am trying to do it in both VB.NET ,Vb6.0
    VB6.0 : same code as given earlier,but error is displayed.

    VB.NET(VS) :
    Public Class Form1
    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    Dim fso As Object
    fso = CreateObject("Scripting.FileSystemObject")
    fso.CopyFile("c:\mydir\*.*", "d:\backup\", True)
    End Sub
    End Class

    But Here too error is displayed "project with an output type of class library cannot be started directly.Need to include exe project.........".

    Please tell me the correct one and the steps to proceed.Thanks again

  7. #7
    Join Date
    Apr 2007
    Location
    Sterling Heights, Michigan
    Posts
    8,663
    I'm not sure what making a backup of a folder has to do with compiling a DLL file from VBScript code, but if you need to do the back in VB.NET, try
    Code:
        Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
            My.Computer.FileSystem.CopyDirectory("c:\mydir\", "d:\backup\")
        End Sub

  8. #8
    Join Date
    Jul 2008
    Posts
    13
    Dear Hack,

    Thanks for the quick replies.I have tried this single line code before,but not working.Kindly could you yourself give me a sample code with steps to convert VBScript to DLL?It'll be a very great help to me.Hoping for reply.Sorry for any inconvenience.

    Cheers
    Last edited by pyar123; 07-16-2008 at 01:13 AM.

  9. #9
    Join Date
    Oct 2004
    Location
    Gainesville, FL
    Posts
    8
    pyar123,

    The error message ""project with an output type of class library cannot be started directly. You need to include exe project........." means that the dll project you are working with cannot be started like an executable file. It needs a host application.

    So, first, in the dll create a new sub and add the code provided by Hack:

    Public Sub BackupMyFiles(ByVal OldPath As String, ByVal NewPath As String)

    My.Computer.FileSystem.CopyDirectory(OldPath , NewPath)

    End Sub

    Build the dll project.

    Second, in the same solution add a new Windows Application project and add a reference to your compiled dll. To test, create a button on the default form and call the dll's function:

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

    Dim FromFolder As String = "c:\myolddir\"
    Dim ToFolder As String = "c:\mynewdir\"
    MyDll.BackupMyFiles(FromFolder, ToFolder)

    End Sub

    Finally, make the Windows Application your Startup project in the properties and build the whole solution. Now you have a host application which uses the dll server and you can start debugging.

  10. #10
    Join Date
    Nov 2004
    Location
    Ottawa, ON, Canada
    Posts
    9
    If you are in "urgent" need, you should pass off the task to someone else. Since it's now 2 weeks passed since initial request the "urgency" must not be. Take some time, do some reading, get back to the very helpful folks here. valboy gave you some good hints to help you along your way but didn't do it for you. That would ruin your fun.

Similar Threads

  1. Convert vbscript to VB2005 Express
    By cjwallaceUK in forum .NET
    Replies: 2
    Last Post: 02-18-2007, 02:21 PM
  2. How to convert a C file into VB DLL
    By Ravi Sankar in forum VB Classic
    Replies: 0
    Last Post: 02-18-2002, 01:43 AM
  3. Replies: 3
    Last Post: 08-01-2001, 01:30 AM
  4. Problem while installing DLL in MTS
    By Antonio Paglia in forum Enterprise
    Replies: 0
    Last Post: 08-29-2000, 12:14 PM
  5. Calling my Class DLL (using VBScript)
    By John K. in forum ASP.NET
    Replies: 3
    Last Post: 03-31-2000, 11:50 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center