Results 1 to 6 of 6

Thread: [RESOLVED] Is it possible to.... ?

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Mar 2010
    Location
    Ireland
    Posts
    85

    Resolved [RESOLVED] Is it possible to.... ?

    I have a basic piece of coding done,

    It works like this:

    I select a surname from a listbox, this loads their address & eye test results.
    (loads into text boxes)

    I then click order.
    (loads a new form *orderform.vb*)

    Now I can enter information into 4 text boxes...

    I would like the surname, address & results to get sent to a letter, and then the new information from the text boxes to get sent to a letter... (.doc or .txt)

    But it has to get sent to a specific part of a pre-written letter...

    Is any of that possible?

    As always, thanks guys.

  2. #2
    eXtreme Programmer .paul.'s Avatar
    Join Date
    May 2007
    Location
    Chelmsford UK
    Posts
    26,413

    Re: Is it possible to.... ?

    create a standard letter template + put place holders in your letter - i.e. [field1], [field2], etc, which you can replace with surname, address & results.

  3. #3

    Thread Starter
    Lively Member
    Join Date
    Mar 2010
    Location
    Ireland
    Posts
    85

    Re: Is it possible to.... ?

    Ok thanks, ehm how do I go about that?

    And what is the VB code then to write into those fields?

    Thanks!

  4. #4
    eXtreme Programmer .paul.'s Avatar
    Join Date
    May 2007
    Location
    Chelmsford UK
    Posts
    26,413

    Re: Is it possible to.... ?

    try this:

    this is an example template txt file:

    Code:
    					[field1]
    					[field2]
    
    
    Dear [field1],
    
                  This is a standard letter that you'll use as a template.


    this is how to use it:

    vb Code:
    1. Dim txtFile As String = IO.File.ReadAllText("template.txt")
    2. txtFile = txtFile.Replace("[field1]", "Mr Doe")
    3. Dim address As String = "Address line1" & Environment.NewLine & New String(ChrW(Keys.Tab), 5) & _
    4. "Address line2" & Environment.NewLine & New String(ChrW(Keys.Tab), 5) & _
    5. "City" & Environment.NewLine & New String(ChrW(Keys.Tab), 5) & "Country"
    6. txtFile = txtFile.Replace("[field2]", address)
    7. IO.File.WriteAllText("newtxtFile.txt", txtFile)
    8. Process.Start("newtxtFile.txt")


    edit:

  5. #5

    Thread Starter
    Lively Member
    Join Date
    Mar 2010
    Location
    Ireland
    Posts
    85

    Re: Is it possible to.... ?

    That's great, thanks...

  6. #6
    eXtreme Programmer .paul.'s Avatar
    Join Date
    May 2007
    Location
    Chelmsford UK
    Posts
    26,413

    Re: [RESOLVED] Is it possible to.... ?

    to automate your printing, use this:

    vb Code:
    1. Dim pr As New ProcessStartInfo
    2. With pr
    3.     .FileName = "newtxtFile.txt"
    4.     .WindowStyle = ProcessWindowStyle.Hidden
    5.     .Verb = "Print"
    6. End With
    7. Process.Start(pr)

Tags for this Thread

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