Form-less applications

Thoth

Freshman
Joined
Jun 27, 2003
Messages
26
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?
 
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
Visual Basic:
System.Windows.Forms.SendKeys.Send("mooo")
Or, at the top of your .vb file (above the Class declaration line) put
Visual Basic:
Imports System.Windows.Forms
Then you'll be able to access the SendKeys class like this:
Visual Basic:
SendKeys.Send("moo")
 
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
 
Last edited:
Back
Top