|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Mixing VB variables with standard text to output text fileI 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 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? In article <ApD2e.25175$ME3.25***@newsfe1-gui.ntli.net>, Scott wrote:
Show quoteHide quote > I wish to create a text document (to the users desktop on any machine) = Const MESSAGE_TEMPLATE As String = "You have chosen a {0}, which is> 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 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] 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 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 In article <IGE2e.25191$ME3***@newsfe1-gui.ntli.net>, Scott wrote:
Show quoteHide quote > Hopefully that will read better... See my original reply...> > 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 > > 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] Hi Tom.
Of course. :-) CorShow quoteHide quote > > 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." > In article <u7QbAsWNFHA.1***@tk2msftngp13.phx.gbl>, Crouchie1998 wrote:
> What is the price per day? Yes you can... I do this all the time. It is a template to pass to> > Tom, > > That format you supplied isn't static text because the variables change, > therefore, you cannot declare it as constant > > 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] 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
Refresh DataSet - please Help Me :-(
Get Variable Out of Arraylist ReInstantiate an Object? Advice needed How can I determine WHICH exception I got in my CATCH? using StringBuilder class for concatenation? foxpro table hosed up when called 2nd time from VB.net SaveFileDialog how to convert... Storing multiple text files inone file. |
|||||||||||||||||||||||