Why The H*ll Doesn't This Work

Hi There

Module Module1

Sub Main()

My.Computer.Printers.DefaultPrinter.WriteLine("Hello World WithOut a Printer").Print()

End Sub

End Module

Cheers
Bronco Billy
"Beer and Fast Women are Ok... No Cigarettes or Hard Liquor Allowed



Answer this question

Why The H*ll Doesn't This Work

  • rjackb

    Hi Daniel

    Thanks but No Thanks...... I started reading your Link and Went to Sleep....  This Program is the Lowest Level VB Printing Program Possible......Why the H*ll Doesn't it Work   I want a Direct Answer Not a Vague Reference.....

    If It Would Work It would Answer A H*ll of Alotta Posts......

    Cheers
    Bronco Billy
    "Beer and Fast Women are Ok... No Cigarettes or Hard Liquor Allowed


  • Morbo

    Try putting your code in form1.load

    I have not been able to get code in sub main to do anything.

       Ed Tenholder


  • David Sadler

    Hi dotNOT4me

    Very Interesting Comments!!!! I Cut my Teeth on IBM Assembler Language.... I think I could Handle C++ or C#....

    Can One Actually Write a Line to a Printer in C++

    Cheers
    Bronco Billy
    "Beer and Fast Women are Ok... No Cigarettes or Hard Liquor Allowed


  • Chad Mumford - MSFT

    Hi There

    You are Right I was a little Hard on Ed and I Apologize if I caused him any Stress...... On the other Hand I thought I stated the problem in the most elementary way possible..... H*ll it’s a VB Henny Youngman.... Also it is Rude to Me for Someone to Respond to a Question When The Do Not Understand the Question.......

    Given: "The problem is that My.Computer doesn't have a member called Printers, I believe that it was pulled out of the release version of .NET 2.0."

    Then How the H*ll does One write a Line to the Printer This is a Show Stopper......

    Cheers
    Bronco Billy
    "Beer and Fast Women are Ok... No Cigarettes or Hard Liquor Allowed


  • Manuel9999

    Hi There

    Hey Ed Get The H*ll Out of This Thread.....  I want a Post From MS or a Current IT Professional .......

    Thanks

    Cheers
    Bronco Billy
    "Beer and Fast Women are Ok... No Cigarettes or Hard Liquor Allowed


  • csallee

    Hi Ed

    Exactly!!!!.... This Is Perfect VB Hello World No Printer Code..... Why The Hell Doesn't It Work   This is Essence..... I don't want BS(B*ll Sh*t).... I wanna know why the SOB Doesn't Work.......  

    Cheers
    Bronco Billy
    "Beer and Fast Women are Ok... No Cigarettes or Hard Liquor Allowed


  • VB Star

    Okay, after a little research:

    In Solution explorer, double-click My Project

    Click Application tab

    If Enable Application Framework is checked, your sub main will never be called.  The framework generates its own sub main that opens up the form you specified, and does all of the other stuff under the Application Framework section.

    You can disable the Application Framework, in which case:

    The Startup Form control will change to Startup Object

    If you have coded a sub Main, you can specify it there to execute

    You will lose all of the other good stuff that the Application framework supplies, but you CAN then provide your own sub main

    Another way to do your own code before your form1 opens, is to code the Application Startup Event instead of using a sub Main (and hence, you can retain the benefits of the Application Framework).  To code the Startup Code, click on the View Application Events (same dialog box as before).  Your code might look like:

    Namespace My

    ' The following events are availble for MyApplication:

    '

    ' Startup: Raised when the application starts, before the startup form is created.

    ' Shutdown: Raised after all application forms are closed. This event is not raised if the application terminates abnormally.

    ' UnhandledException: Raised if the application encounters an unhandled exception.

    ' StartupNextInstance: Raised when launching a single-instance application and the application is already active.

    ' NetworkAvailabilityChanged: Raised when the network connection is connected or disconnected.

    Partial Friend Class MyApplication

    Private Sub MyApplication_Startup( _

    ByVal sender As Object, _

    ByVal e As Microsoft.VisualBasic.ApplicationServices.StartupEventArgs _

    ) Handles Me.Startup

    MsgBox("hello world")

    End Sub

    End Class

    End Namespace

      Hope this helps,

           Ed Tenholder


  • leonvanrooijen

    Bronco Billy,

    First of all, could you please not be rude other users of the forum. They are trying to help, and responding to them like that is not fair.

    Second of all, try and provide more information when you post a question, for example, if you had simply said that the above code doesn't actually compile (and provide the error), then other users could tell you exactly what was wrong.

    The problem is that My.Computer doesn't have a member called Printers, I believe that it was pulled out of the release version of .NET 2.0.

     



  • mohsin08

    .NET where 2+2 is 5 and nothing works in debug mode.

    Pick a different language that will never change, such as C++, and stick to it. They're going to keep changing the VB language so they can continually sell you classes, books, certifications & so on.

    When less then 10% of the VB6 ub didn't move forward, they tried to give it away for free and that's about what it's worth.

    There is your post from an IT professional sir.



  • dcleary

  • Gabriel Lozano-Moran

    Hi,

    In Visual Studio 2005 we've tried but could not find a good enough solution for My.Computer.Printers. Due to the resource constrain, this feature was cut in the final release of the product. We will continue to investigate to improve the printing experience in the next release.

    For now, you can take a look at this article http://msdn.microsoft.com/library/default.asp url=/library/en-us/dv_vbcode/html/vbtskCodeExamplePrintingTextFile.asp.

    Best regards,



  • Why The H*ll Doesn't This Work