Link to home
Start Free TrialLog in
Avatar of stephaniem712
stephaniem712

asked on

Easiest way to make a visual basic.net program automated

I created a program for a client that extracts data from a database and then writes it to a textfile.  I originally built it with a form with a button that they would need to click to start the program.  A message then pops up that the export completed successfully and then they have to close the program.  They now do not want any of this.  They want to be able to schedule the .exe using windows scheduler.  What is the easiest way to make this program automated?  I want to remove the form, button etc....  

Thanks!!!!
ASKER CERTIFIED SOLUTION
Avatar of Mike Tomlinson
Mike Tomlinson
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of stephaniem712
stephaniem712

ASKER

I created a new project and added a module.  I copied the code as instructed and I'm getting messages that I need to declare
psCompanyINI
psCompany.....etc. even though they are all declared as shown below in the piece fo code I attached..

Module DataExport

    Public SubMain()


    Dim FILE_NAME As String = "C:\Rolligon\Data\POPayHist.txt"
    Dim psCompanyINI As String = ""
    Dim psCompany As String = ""
    Dim psUN As String = ""
    Dim psPW As String = ""

    Dim textr As TextReader = New StreamReader("C:\ExportINI.txt", False)

        psCompanyINI = textr.ReadToEnd
        textr.Close()
        psCompany = Split(psCompanyINI, "Company=")(1).Split(ControlChars.CrLf)(0)
        psUN = Split(psCompanyINI, "UN=")(1).Split(ControlChars.CrLf)(0)
        psPW = Split(psCompanyINI, "PW=")(1).Split(ControlChars.CrLf)(0)
You sure have the spaces in there correctly and the mathching End XXX parts?
Module DataExport
 
    Public Sub Main()
        Dim FILE_NAME As String = "C:\Rolligon\Data\POPayHist.txt"
        Dim psCompanyINI As String = ""
        Dim psCompany As String = ""
        Dim psUN As String = ""
        Dim psPW As String = ""
 
        Dim textr As New StreamReader("C:\ExportINI.txt", False)
        psCompanyINI = textr.ReadToEnd
        textr.Close()
        psCompany = Split(psCompanyINI, "Company=")(1).Split(ControlChars.CrLf)(0)
        psUN = Split(psCompanyINI, "UN=")(1).Split(ControlChars.CrLf)(0)
        psPW = Split(psCompanyINI, "PW=")(1).Split(ControlChars.CrLf)(0)
    End Sub
 
End Module

Open in new window

I created a new project - a windows application.  Is this correct?  It includes a form.  When I delete the form and copy in the code (which now appears to be ok), I get build errors..  having to do with the deleted form..
You need to go into Project --> Properties and change the "Startup Object" to "Sub Main".
I apologize. You did say that.  That worked!   Thanks for the help!!