Results 1 to 4 of 4

Thread: Printing to Notepad and Open with results (Resolved)

  1. #1

    Thread Starter
    Junior Member Willie's Avatar
    Join Date
    Nov 2002
    Location
    Michigan
    Posts
    20

    Printing to Notepad and Open with results (Resolved)

    I need a basic example to carry the results of a form to notepad and open notepad with the values passed.

    If you could just give me an example of how to print "Hello World!" to Notepad and open Notepad after the value has been passed, then I think I can do the rest myself.

    Your help will be appreciated.
    Last edited by Willie; Nov 28th, 2002 at 03:57 AM.
    Willie

  2. #2
    PowerPoster jdc2000's Avatar
    Join Date
    Oct 2001
    Location
    Idaho Falls, Idaho USA
    Posts
    2,526
    VB Code:
    1. Private Sub Command1_Click()
    2.  
    3.     Dim strTemp1 As String
    4.     Dim lngTemp1 As Long
    5.    
    6.     strTemp1 = "C:\Testabcd.txt"
    7.     Open strTemp1 For Output As #1
    8.     Print #1, "Hello World!"
    9.     Close #1
    10.     lngTemp1 = Shell("Notepad.exe " + strTemp1, vbNormalFocus)
    11.  
    12. End Sub

  3. #3
    Fanatic Member joltremari's Avatar
    Join Date
    Sep 2000
    Location
    Mississippi
    Posts
    674
    The simplest example I can give is:
    VB Code:
    1. Text1.text = "Hello World"
    2. Open "C:\[I]FolderName[/I]\[I]FileName[/I].txt" For Output As #1
    3.    Print #1, Text1.Text
    4. Close #1
    5.  
    6. Shell "Notepad.exe C:\[I]FolderName[/I]\[I]FileName[/I].txt", vbNormalFocus
    7.  
    8. 'To Print it
    9. Shell "Notepad.exe /p C:\[I]FolderName[/I]\[I]FileName[/I].txt", vbNormalFocus

    There are other ways, this is just the simplest I know
    Hope this helps

    JO
    "I have not failed. I've just found 10,000 ways that won't work."
    'Thomas Edison'

    "If we knew what it was we were doing it wouldn't be called research, would it?"
    'Albert Einstein'

    VB6

  4. #4

    Thread Starter
    Junior Member Willie's Avatar
    Join Date
    Nov 2002
    Location
    Michigan
    Posts
    20

    Thank you both.

    I got it to work and I get the idea. I have one more question about your code.

    Why do you Dim the file location as Long? I thought Long was only used for a numeric value?

    Why do you both use "for Output as #1"? Could I change #1 to #2 or #3? (or is this just something people do like using i for temporary numeric values? kind of like programming etiquette )

    Thanks agian!
    Willie

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