Thoth Posted July 8, 2003 Posted July 8, 2003 I'm trying to design some small applications, and these applications don't necessarily need to have forms, in fact it is better if they don't. All I want is the program to run, give a message that it's run, and then quit. In Visual Studio .NET 2003, when I try to create an Empty Project (using VB .NET), and I start writing my Main, I notice I can't use many of the functions I normally could in a Windows Application, like SendKeys, for example. Is there any way I can get all the functions I need without having to deal with forms? Quote Still getting my head around this ADO stuff... sigh.
wyrd Posted July 8, 2003 Posted July 8, 2003 You could always try creating an app with the forms visibility set to false. Quote Gamer extraordinaire. Programmer wannabe.
*Experts* Volte Posted July 8, 2003 *Experts* Posted July 8, 2003 You can still use the SendKeys class in a formless project; when you create the project, right click the 'References' item in the Solution Explorer and click Add. Find System.Windows.Forms.dll in the list and add it to the project references list. You can use SendKeys now by using System.Windows.Forms.SendKeys.Send("mooo")Or, at the top of your .vb file (above the Class declaration line) putImports System.Windows.FormsThen you'll be able to access the SendKeys class like this:SendKeys.Send("moo") Quote
Thoth Posted July 9, 2003 Author Posted July 9, 2003 (edited) This code won't compile, saying that there's no suitable main method. Can anyone tell me what I need to do to make this thing happy? Imports System.Windows.Forms 'Program to insert a comment with the current name and date into the open application. Public Class CommentHeader Sub Main() Dim Name, Time As String 'Get the current time. Time = System.DateTime.Now.ToString 'Get the name of the user logged in. Name = Environment.UserName 'Send the information to the appropriate application. SendKeys.Send("'" & Time & " " & Name) End Sub End Class Edited July 9, 2003 by Thoth Quote Still getting my head around this ADO stuff... sigh.
*Experts* mutant Posted July 9, 2003 *Experts* Posted July 9, 2003 You need to make your sub Shared: Shared Sub Main() Quote
Thoth Posted July 9, 2003 Author Posted July 9, 2003 Thanks for your help guys, the program now works as specified. Quote Still getting my head around this ADO stuff... sigh.
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.