Results 1 to 9 of 9

Thread: Is this usage of With illegal?

  1. #1

    Thread Starter
    vbuggy krtxmrtz's Avatar
    Join Date
    May 2002
    Location
    In a probability cloud
    Posts
    5,573

    Is this usage of With illegal?

    I'm getting an error at the .Print line. Is this illegal at all or does it require a different syntax?

    With Printer
    .Print whatever
    End With
    Lottery is a tax on people who are bad at maths
    If only mosquitoes sucked fat instead of blood...
    To do is to be (Descartes). To be is to do (Sartre). To be do be do (Sinatra)

  2. #2
    Frenzied Member Buzby's Avatar
    Join Date
    Jan 1999
    Location
    UK
    Posts
    1,670
    You'll notice that the .PRINT method of PRINTER doesn't appear in intellisense either..

    What you are getting is a compiler error - the compiler doesn't know about the .PRINT method so it reckons it can't deal with it.
    Other methods (like .ENDDOC etc) work fine.

    However, if the compiler were to ignore the error and continue it would find that it would work after all.

    Unfortunately, as far as I know, you can't tell the compiler to ignore errors so you will just have to do

    With Printer
    Printer.Print "hello"
    .EndDoc
    End With
    'Buzby'
    Visual Basic Developer
    "I'm moving to Theory. Everything works there."

  3. #3
    Frenzied Member Robbo's Avatar
    Join Date
    Jan 2001
    Location
    Bradford
    Posts
    1,143
    use F1,

    Printer is that a variable/interger

    whats the whatever bit going to be just a tag?

    if you want to print, then depends where, think .print, prints on the form itself?
    -----------------------------------------------
    "The hall is rented,"
    "the orchestra is engaged,"
    "its now time to see if you can dance!"
    Q, Q-Who, Star Trek The Next Generation
    -----------------------------------------------
    General Work day

    -----------------------------------------------
    DOS, Win 95, Win 98 SE, Win ME, Win NT 4.0 SP6a, Windows 2000 SP3, Window XP SP1, Windows 7, Windows 8/8.1, Windows 10, Office 97 Pro, Office 2000 Pro, Office 2010, Office 2013, Office 2016, Office 2019, Visual Basic 6 (SP5), SQL, Oracle

  4. #4
    Hyperactive Member AvisSoft's Avatar
    Join Date
    Sep 2002
    Location
    Chandigarh
    Posts
    459
    Have you installed a printer ? There's no Printer.Print in my VB. The With is okay!
    Tapan Bhanot,
    CEO, Avis Software.
    Website: www.avissoftware.com

  5. #5
    Frenzied Member Buzby's Avatar
    Join Date
    Jan 1999
    Location
    UK
    Posts
    1,670
    Robbo, PRINTER is a VB object for talking to the printer - in the same way as SCREEN is for talking to the screen.

    It's just that the PRINTER object seems to have been written in someone's lunch hour and the .PRINT method isn't exposed in the intellisense so it doesn't work within WITH commands.
    'Buzby'
    Visual Basic Developer
    "I'm moving to Theory. Everything works there."

  6. #6
    Frenzied Member Buzby's Avatar
    Join Date
    Jan 1999
    Location
    UK
    Posts
    1,670
    AvisSoft, just because it doesn't appear in the intellisense drop-down it doesn't mean it doesn't exist.

    In VB4 we had to write code without intellisense - boy was that fun trying to discover the properties, methods and events of objects !
    'Buzby'
    Visual Basic Developer
    "I'm moving to Theory. Everything works there."

  7. #7

    Thread Starter
    vbuggy krtxmrtz's Avatar
    Join Date
    May 2002
    Location
    In a probability cloud
    Posts
    5,573
    Originally posted by Buzby
    It's just that the PRINTER object seems to have been written in someone's lunch hour
    or maybe by someone having a joint...?
    Well, at least I wasn't mistyping...
    Lottery is a tax on people who are bad at maths
    If only mosquitoes sucked fat instead of blood...
    To do is to be (Descartes). To be is to do (Sartre). To be do be do (Sinatra)

  8. #8
    The picture isn't missing BuggyProgrammer's Avatar
    Join Date
    Oct 2000
    Location
    Vancouver, Canada
    Posts
    5,217
    It also doesn't work with the Print method of the forn, picturebox, and any other controls that has that thing.

    and Robbo, that is a HUGE signature... maybe you can trim it down a bit? (I mean it should be less than 10 lines)
    Remember, if someone's post was not helpful, you can always rate their post negatively .

  9. #9
    Hyperactive Member AvisSoft's Avatar
    Join Date
    Sep 2002
    Location
    Chandigarh
    Posts
    459
    Hi!

    yes i understand. as far as i have seen the most complex thing in vb is printing. graphics, database, programming, winsock..all other stuff is easy...just printing is a pain...i hope one day this problem will also be solved.

    instead of using 3rd party reporting tools there's should be something which is in the vb itself. i don't know weather .net has something or not...but as far as i am concerned crystal reports sucks!

    thanks!
    Tapan Bhanot,
    CEO, Avis Software.
    Website: www.avissoftware.com

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width