CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 6 of 6

Thread: Form As Text?

  1. #1
    Guest

    Form As Text?

    I am a beginning VB student and learning this intersting program. My Teacher is asking on his lab 4 things he wants.
    1>Program Code (thats easy thats just the coding I got that)
    2>Program Forms<Form Image> (if I am correct I made a cap file of the screen before it was run>
    3>Form as Text <no idea what this means help!!!>
    4> 3 Output screens <means caps of 3 different test runs ...no prob>
    So if any of you out there can help me with #3 and 2 if I have that wrong that would grately be appreciated. Thanks.


  2. #2

    Re: Form As Text?

    you really should ask you prof if you need help with what he wants. But to get a form to text you need to go to File then Print and you'll see an option for printing forms to text


  3. #3
    Join Date
    Aug 1999
    Location
    US, Florida
    Posts
    817

    Re: Form As Text?

    Set form properties to autoredraw = true
    or just place this code into a Form_load()

    me.AutoRedraw = true
    print "Hello"


    I have one question tho, can you tell VB to print "Hello" in the center for example?? or it's imposible to tell VB to print text somewhere else but top-left corner (0,0)


  4. #4

    Re: Form As Text?

    you could always create a label and dynamically move the label at run time.


  5. #5
    Join Date
    May 1999
    Location
    Oxford UK
    Posts
    1,459

    Re: Form As Text?

    >I have one question tho, can you tell VB to print "Hello" in the center
    >for example?? or it's imposible to tell VB to print text somewhere else
    >but top-left corner (0,0)

    You need to mess around with the Form's 'CurrentX' and 'CurrentY' properties (the printer and picturebox have these properties also).

    Note that this code doesn't take into account the height of the windows caption bar so it may appear as if the height isn't centered properly (although it is in client/space terms).


    Dim sText as string
    '
    sText = "Hello World"
    '
    ' You will need to take into account the standard
    ' form caption bar height if you want it to appear
    ' 'dead' center - this just places it in the center
    ' of the available area
    '
    me.CurrentX = (me.Width / 2) - (TextWidth(sText) / 2)
    me.CurrentY = (me.Height / 2)
    '
    me.print sText
    '






    Chris Eastwood

    CodeGuru - the website for developers
    http://codeguru.developer.com/vb

  6. #6
    Join Date
    May 1999
    Location
    Oxford UK
    Posts
    1,459

    Re: Form As Text?

    You can simply load the vb form file into notepad and print it out that way (or just save it as a 'txt' file).

    In VB3 (and 4 ?) there used to be an option for saving forms in a binary format but this used to go horribly wrong sometimes. Now all VB files in your project are saved in a text-based format (at least, I can't find the option to save as binary anywhere).

    As for the screen capturing, simply do a CTRL or ALT and PrintScreen (depending on what you want to do!) and paste into PaintBrush / PSP / Word or a similar package.



    Chris Eastwood

    CodeGuru - the website for developers
    http://codeguru.developer.com/vb

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

Featured