|
-
Mar 7th, 2010, 02:24 AM
#1
Thread Starter
Lively Member
[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.
-
Mar 7th, 2010, 05:57 AM
#2
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.
- Coding Examples:
- Features:
- Online Games:
- Compiled Games:
-
Mar 7th, 2010, 09:45 AM
#3
Thread Starter
Lively Member
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!
-
Mar 7th, 2010, 10:03 AM
#4
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:
Dim txtFile As String = IO.File.ReadAllText("template.txt")
txtFile = txtFile.Replace("[field1]", "Mr Doe")
Dim address As String = "Address line1" & Environment.NewLine & New String(ChrW(Keys.Tab), 5) & _
"Address line2" & Environment.NewLine & New String(ChrW(Keys.Tab), 5) & _
"City" & Environment.NewLine & New String(ChrW(Keys.Tab), 5) & "Country"
txtFile = txtFile.Replace("[field2]", address)
IO.File.WriteAllText("newtxtFile.txt", txtFile)
Process.Start("newtxtFile.txt")
edit:
- Coding Examples:
- Features:
- Online Games:
- Compiled Games:
-
Mar 7th, 2010, 10:31 AM
#5
Thread Starter
Lively Member
Re: Is it possible to.... ?
That's great, thanks...
-
Mar 7th, 2010, 10:54 AM
#6
Re: [RESOLVED] Is it possible to.... ?
to automate your printing, use this:
vb Code:
Dim pr As New ProcessStartInfo
With pr
.FileName = "newtxtFile.txt"
.WindowStyle = ProcessWindowStyle.Hidden
.Verb = "Print"
End With
Process.Start(pr)
- Coding Examples:
- Features:
- Online Games:
- Compiled Games:
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|