By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,556 Members | 1,446 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,556 IT Pros & Developers. It's quick & easy.

Mixing VB variables with standard text to output text file

P: n/a
I wish to create a text document (to the users desktop on any machine) which outputs to a standard text file with information obtained from there use of my program... Some of the text will be fixed and some will be variables generated in VB.net. For example...

You have chosen a SINGLE TRIP, which is within EUROPE and is for FAMILY and last for 27 days. The trips starts from 24/04/05 until 30/04/05 and you chose to use more than 17 days of winter sports. The total price for your trip 155.00.

The BOLD CAPS mean they are variables from VB.net.

Any help would be appreciated!!!

Scott
Nov 21 '05 #1
Share this Question
Share on Google+
8 Replies


P: n/a
Where's the code from your program?

Will the users have a text box to enter the length of time & datetimepickers to select the start/end dates?

Will the program be run locally or from the server?
Nov 21 '05 #2

P: n/a
In article <Ap*******************@newsfe1-gui.ntli.net>, Scott wrote:
I wish to create a text document (to the users desktop on any machine) =
which outputs to a standard text file with information obtained from =
there use of my program... Some of the text will be fixed and some will =
be variables generated in VB.net. For example...

You have chosen a SINGLE TRIP, which is within EUROPE and is for FAMILY =
and last for 27 days. The trips starts from 24/04/05 until 30/04/05 and =
you chose to use more than 17 days of winter sports. The total price =
for your trip =A3155.00.

The BOLD CAPS mean they are variables from VB.net.

Any help would be appreciated!!!

Scott


Const MESSAGE_TEMPLATE As String = "You have chosen a {0}, which is
within {1} and is for {2} and lasts for 27 days. The trip starts from
24/04/05 until 30/04/05 and you chose to use more than 17 days of winter
sports. The total price for your trip is $155.00"
Dim Message As String = String.Fromat (MESSAGE_TEMPLATE, tripVariable,
placeVariable, familyVariable)

Anyway, something like that :) I have a hard time reading you message
because it was in html format - and I only use a text only reader :)

--
Tom Shelton [MVP]
Nov 21 '05 #3

P: n/a
What is the price per day?

Tom,

That format you supplied isn't static text because the variables change,
therefore, you cannot declare it as constant
Nov 21 '05 #4

P: n/a
Hopefully that will read better...

I need to output to a new file that must be created on the desktop... a lot
of the code is pre-fixed with the variables filling in the blanks... The
most important thing is saving to the desktop on any particular machine,
within the network...

Here is the original text I wrote...

I wish to create a text document (to the users desktop on any machine) which
outputs to a standard text file with information obtained from there use of
my program... Some of the text will be fixed and some will be variables
generated in VB.net. For example...

You have chosen a SINGLE TRIP, which is within EUROPE and is for FAMILY and
last for 27 days. The trips starts from 24/04/05 until 30/04/05 and you
chose to use more than 17 days of winter sports. The total price for your
trip 155.00.

The BOLD CAPS mean they are variables from VB.net.

Any help would be appreciated!!!

Scott
Nov 21 '05 #5

P: n/a
Scot,

You mean something as this

"You have chosen a @1, which is within @2 is for @3............"

String1 = String1.Replace("@1","Single Trip") 'probably a datafield.
String1 = String1.Replace("@2 etc)

This is not a quick method however for this small string not slow too, very
easy and good documentative in my opinion.

I hope this helps,

Cor
Nov 21 '05 #6

P: n/a
In article <u7**************@tk2msftngp13.phx.gbl>, Crouchie1998 wrote:
What is the price per day?

Tom,

That format you supplied isn't static text because the variables change,
therefore, you cannot declare it as constant


Yes you can... I do this all the time. It is a template to pass to
string.format.

Try it:
Option Strict On
Option Explicit On

Public Class Example
Private Const FORMAT_TEMPLATE As String = "Hi {0}"

Public Shared Sub Main ()
Dim Message As String = String.Format (FORMAT_TEMPLATE, "Crouchie")

Console.WriteLine (Message)
End Sub
End Class

--
Tom Shelton [MVP]
Nov 21 '05 #7

P: n/a
In article <IG****************@newsfe1-gui.ntli.net>, Scott wrote:
Hopefully that will read better...

I need to output to a new file that must be created on the desktop... a lot
of the code is pre-fixed with the variables filling in the blanks... The
most important thing is saving to the desktop on any particular machine,
within the network...

Here is the original text I wrote...

I wish to create a text document (to the users desktop on any machine) which
outputs to a standard text file with information obtained from there use of
my program... Some of the text will be fixed and some will be variables
generated in VB.net. For example...

You have chosen a SINGLE TRIP, which is within EUROPE and is for FAMILY and
last for 27 days. The trips starts from 24/04/05 until 30/04/05 and you
chose to use more than 17 days of winter sports. The total price for your
trip 155.00.

The BOLD CAPS mean they are variables from VB.net.

Any help would be appreciated!!!

Scott


See my original reply...

Option Strict On
Option Explicit On

Imports System

Public Class Example
Private Const String MESSAGE_TEMPLATE = _
"You have chosen a {0}, which is within {1} and is for {2} and last for 27 days. The trips starts from 24/04/05 until 30/04/05 and you chose to use more than 17 days of winter sports. The total price for your trip 155.00."

Public Shared Sub Main ()

Console.WriteLine _
(MESSAGE_TEMPLATE, "SINGLE TRIP", "EUROPE", "FAMILY")
End Sub
End Class

You could also format it to a string using String.Format...
Dim Message As String = String.Format _
(MESSAGE_TEMPLATE, "SINGLE TRIP", "EUROPE", "FAMILY")
Console.WriteLine (Message)
--
Tom Shelton [MVP]
Nov 21 '05 #8

P: n/a
Hi Tom.

Of course.

:-)

Cor

Public Class Example
Private Const String MESSAGE_TEMPLATE = _
"You have chosen a {0}, which is within {1} and is for {2} and last for 27
days. The trips starts from 24/04/05 until 30/04/05 and you chose to use
more than 17 days of winter sports. The total price for your trip
155.00."

Nov 21 '05 #9

This discussion thread is closed

Replies have been disabled for this discussion.