Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

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?

Still getting my head around this ADO stuff... sigh.
  • *Experts*
Posted

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) put

Imports System.Windows.Forms

Then you'll be able to access the SendKeys class like this:

SendKeys.Send("moo")

Posted (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 by Thoth
Still getting my head around this ADO stuff... sigh.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...