Solved

Easiest way to make a visual basic.net program automated

Posted on 2008-06-25
6
181 Views
Last Modified: 2013-11-26
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!!!!
0
Comment
Question by:stephaniem712
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 3
6 Comments
 
LVL 85

Accepted Solution

by:
Mike Tomlinson earned 500 total points
ID: 21867309
For VB.Net 2003, add a Module and make a Public Sub Main in there.  Then put your code in "sub main".  Finally change the "startup object" in Project --> Properties to "sub main" and recompile.  The new exe should simply run your code and then end.

Module Module1
 
    Public Sub Main()
        ' ... put your code in here ...
    End Sub
 
End Module

Open in new window

0
 

Author Comment

by:stephaniem712
ID: 21868604
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)
0
 
LVL 85

Expert Comment

by:Mike Tomlinson
ID: 21868860
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

0
How our DevOps Teams Maximize Uptime

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us. Read the use case whitepaper.

 

Author Comment

by:stephaniem712
ID: 21869061
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..
0
 
LVL 85

Expert Comment

by:Mike Tomlinson
ID: 21869108
You need to go into Project --> Properties and change the "Startup Object" to "Sub Main".
0
 

Author Comment

by:stephaniem712
ID: 21869328
I apologize. You did say that.  That worked!   Thanks for the help!!
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In my previous two articles we discussed Binary Serialization (http://www.experts-exchange.com/A_4362.html) and XML Serialization (http://www.experts-exchange.com/A_4425.html). In this article we will try to know more about SOAP (Simple Object Acces…
For those of you who don't follow the news, or just happen to live under rocks, Microsoft Research released a beta SDK (http://www.microsoft.com/en-us/download/details.aspx?id=27876) for the Xbox 360 Kinect. If you don't know what a Kinect is (http:…
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…

756 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question