473,394 Members | 1,737 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

Which is a better method to concatenate large blocks of text?

In a Windows Form application, which is the better method to concatenate
large blocks of code?

1. Reading the text from text files.
2. Adding the text to the VB file itself?

Thanks!
J.S.

--
Nov 21 '05 #1
14 2306
J.S.
In a Windows Form application, which is the better method to concatenate
large blocks of code?
Can you explain more with concatentate large blocks of code?

1. Reading the text from text files.
2. Adding the text to the VB file itself?

That depends on what you are doing, you can even add by instance adding the
text from a database.

Cor
Nov 21 '05 #2
> Can you explain more with concatentate large blocks of code?

I am trying to create a Windows application in VB 2005 beta that has a form
with some textboxes. The values entered in the textboxes are variables
which I want to integrate with some other blocks of code (which I have) to
generate code for another application. So the code thus generated would be
based on concatenating some blocks of code (say for example, ASP code) with
the variable values entered by the users. I have managed to do this two
ways - by inserting the blocks of code also in the VB file, and by pulling
the blocks of code from external text files on my computer.

My question is: which of these methods is better from a performance and
"best practices" standpoint? If I integrate all the code into the VB file
then users will just need an .exe file to work with my application. If I
pull blocks of code from external text files then I'll have to create text
files on their computers as well when my assembly is unzipped by them.
That depends on what you are doing, you can even add by instance adding
the text from a database.


You are right; a database would be a good method in many instances. In this
application, however, I'd rather use one of the above methods unless there
are significant reasons not to do so. The reason I use text files in one
method is because I don't know if I could convert the text files into some
kind of binary and still have it be read by my application.

Thanks for your help; I am a complete newbie at this.

J.S.
Nov 21 '05 #3
J.S.

I definitly would not do it with the exe file. If you have no problem that
the user can see the file, than probably (if I understand you well), I would
go for the XML dataset because that is terrible easy to handle.

In VB 2005 it should also be possible to use direct the datatable XML for
this

I hope this helps.

Cor
Nov 21 '05 #4
Hi Cor,

That is exactly what I was looking for. Thanks for your kind advice.

J.S.

--

"Cor Ligthert [MVP]" <no************@planet.nl> wrote in message
news:Ol**************@TK2MSFTNGP12.phx.gbl...
J.S.

I definitly would not do it with the exe file. If you have no problem that
the user can see the file, than probably (if I understand you well), I
would go for the XML dataset because that is terrible easy to handle.

In VB 2005 it should also be possible to use direct the datatable XML for
this

I hope this helps.

Cor

Nov 21 '05 #5
On 2005-08-21, J.S. <js*@nospam.com> wrote:
Can you explain more with concatentate large blocks of code?


I am trying to create a Windows application in VB 2005 beta that has a form
with some textboxes. The values entered in the textboxes are variables
which I want to integrate with some other blocks of code (which I have) to
generate code for another application. So the code thus generated would be
based on concatenating some blocks of code (say for example, ASP code) with
the variable values entered by the users. I have managed to do this two
ways - by inserting the blocks of code also in the VB file, and by pulling
the blocks of code from external text files on my computer.

My question is: which of these methods is better from a performance and
"best practices" standpoint? If I integrate all the code into the VB file
then users will just need an .exe file to work with my application. If I
pull blocks of code from external text files then I'll have to create text
files on their computers as well when my assembly is unzipped by them.


Performance-wise, pulling from a text file is going to be slower, but
I seriously doubt that the difference is going to be significant, so I
really wouldn't worry about that at all.

Contra Cor, I also don't like the idea of datasets for this. That's just
going to make your input files difficult to read and difficult to edit.

Also, by "inserting the blocks of code in the VB file", do you mean
defining them as strings? If so, I also don't like this idea, since
long string blocks are really hard to read.

There's the third choice here, which is to add the text files to
your project and embed them in the applicatio as embedded resources.
I'd lean towards this for a few reasons: a) they're still text files,
and so they're easy to edit, b) they're easy to version and there's no
chance of the wrong version of a text file winding up with the wrong
version of your app, c) installation stays simple since you still have
just the one exe file.

Nov 21 '05 #6
> Contra Cor, I also don't like the idea of datasets for this. That's just
going to make your input files difficult to read and difficult to edit.

Can you explain this?

In my opinion XML datasets are extremely easy to read, to use the data and
to edit, therefore I should miss something?

Cor
Nov 21 '05 #7
"dfoster" <df*****@woofix.local.dom> wrote in message
news:sl********************@localhost.localdomain. ..
Performance-wise, pulling from a text file is going to be slower, but
I seriously doubt that the difference is going to be significant, so I
really wouldn't worry about that at all.
Thanks!
Also, by "inserting the blocks of code in the VB file", do you mean
defining them as strings? If so, I also don't like this idea, since
long string blocks are really hard to read.
Yes, that's what I meant. For example:

Textbox1.Text = "Some code" &_
"Some more code" & Var1 &_
"Lots more code" & Var2 &_
so on and so forth
There's the third choice here, which is to add the text files to
your project and embed them in the applicatio as embedded resources.
I'd lean towards this for a few reasons: a) they're still text files,
and so they're easy to edit, b) they're easy to version and there's no
chance of the wrong version of a text file winding up with the wrong
version of your app, c) installation stays simple since you still have
just the one exe file.


I have been looking at embedded resources. There I two questions I am
wondering about this:

1. Is it correct that at design-time the text files would be separate but
would be embedded into the .exe file when the assembly is built?

2. If the text files are going to remain embeddeed in the .exe and not be
unzipped then how would I change the path for the text file in my VB file?

For example, now I have something like c:\textfile.txt. If I want to read
text from an embedded text file the path must be something else since there
will be no separate textfile.txt at run-time.

Thanks,
J.S.
Nov 21 '05 #8
I found some information about resources here:
http://msdn.microsoft.com/library/de...yResgenexe.asp

--

"J.S." <js*@nospam.com> wrote in message
news:ua**************@TK2MSFTNGP15.phx.gbl...
I have been looking at embedded resources. There I two questions I am
wondering about this:

1. Is it correct that at design-time the text files would be separate but
would be embedded into the .exe file when the assembly is built?

2. If the text files are going to remain embeddeed in the .exe and not be
unzipped then how would I change the path for the text file in my VB file?

For example, now I have something like c:\textfile.txt. If I want to read
text from an embedded text file the path must be something else since
there will be no separate textfile.txt at run-time.

Nov 21 '05 #9
On 2005-08-21, Cor Ligthert [MVP] <no************@planet.nl> wrote:
Contra Cor, I also don't like the idea of datasets for this. That's just
going to make your input files difficult to read and difficult to edit.

Can you explain this?

In my opinion XML datasets are extremely easy to read, to use the data and
to edit, therefore I should miss something?


Often that's true, but remember the OP is dealing with code blocks here.
Long bits of (presumably) VB code in text files. Text files with VB
in them are easy to edit, you just load them into an editor and you get
syntax coloring, autoindentation, maybe even some intellisense depending
on what's in the file.

Move them into a DataSet Xml file though and all that goes away.
The editor won't recognize the text file as VB, and you'll have to deal
with entities for all invalid characters. And code blocks tend to have
quite a few '>' and '<' characters in them.

Nov 21 '05 #10
On 2005-08-22, J.S. <js*@nospam.com> wrote:
"dfoster" <df*****@woofix.local.dom> wrote in message
news:sl********************@localhost.localdomain. ..
I have been looking at embedded resources. There I two questions I am
wondering about this:

1. Is it correct that at design-time the text files would be separate but
would be embedded into the .exe file when the assembly is built?
Correct.
2. If the text files are going to remain embeddeed in the .exe and not be
unzipped then how would I change the path for the text file in my VB file?

For example, now I have something like c:\textfile.txt. If I want to read
text from an embedded text file the path must be something else since there
will be no separate textfile.txt at run-time.


It depends on how you use namespaces in your app. The name of the
embedded resource is namespace/filename. In the simplest case where
everything is in a single namespace, you just call

GetManifestResourceStream(Me.GetType(), "textfile.txt")

There's a lot of sites on the Net that describe all this in detail, but
it's pretty straightforward.

Nov 21 '05 #11
> It depends on how you use namespaces in your app. The name of the
embedded resource is namespace/filename. In the simplest case where
everything is in a single namespace, you just call

GetManifestResourceStream(Me.GetType(), "textfile.txt")

There's a lot of sites on the Net that describe all this in detail, but
it's pretty straightforward.


Thanks! I appreciate your help.

J.S.
Nov 21 '05 #12
J.S.
In addition to the other comments:

It sounds like you are building some type of "Code Generator" where you have
a template & then insert "variables" into this template. Correct?

I would consider using Xml (not specifically a DataSet) to store the
"template" itself in.

Then I would use System.Xml.XPath namespace to read the "template" & the
System.CodeDom namespace to generate the source file.

In many ways using a DataSet to read the Xml file is both easier & harder
then using an XPathNavigator object (from System.Xml.XPath).

The Xml file could either define the structure of your template directly
(ala XSLT) or it could include snippets of code that you use one of the
CodeSnippet* classes to piece the pieces together. The advantage of using
Xml to define the structure directly is that you could then allow your code
generator to support languages other then VB, as the template itself would
not have any language (VB, C#) specific constructs in it, it would only have
abstract Xml constructs. The "variables" that you define would be in a
specific language, however it sounds like your user is typing the values of
these variables any way.

NOTE: I would use one of the CodeSnippet* classes to inject what the user is
entering into the generated CodeDom file...

FWIW: ASP.NET, XSD.EXE & WDSL.EXE all use the CodeDom for their code
generation. I understand that VS.NET has its own Code Serializer that may or
may not leverage the CodeDom.

Alternatively I would consider using either an XSLT to transform the
template & "variables" into a .vb file. In some ways I see XSLT as being the
"easier" but more "restrictive" approach...

Hope this helps
Jay

"J.S." <js*@nospam.com> wrote in message
news:OC**************@TK2MSFTNGP15.phx.gbl...
| In a Windows Form application, which is the better method to concatenate
| large blocks of code?
|
| 1. Reading the text from text files.
| 2. Adding the text to the VB file itself?
|
| Thanks!
| J.S.
|
| --
|
|
Nov 21 '05 #13
Hi Jay,

You guessed correctly. :-)

Thanks for a detailed response. I find your advice intriguing because with
it I think I could use one XML file with many code snippets instead of using
several text files, one for each code snippet. I am going to read up on the
things you mentioned and try to implement what you have suggested.

Till now I was trying a different approach and I am curious to hear what you
think about that. My text file has various parameters that match the name
of textboxes and other controls on my windows forms. For example, embedded
inside the text file are parameters such as @@TextBox1@@, @@TextBox2@@,
@@ComboBox1@@, etc. I was thinking of replacing the parameter @@Textbox1@@
in the text file with the value of TextBox1 on the Form user interface (UI)
and parameter @@TextBox2@@ with the value entered in textBox2 in the Form
UI. What do you think of this approach?

Thanks,
J.S.

--

"Jay B. Harlow [MVP - Outlook]" <Ja************@msn.com> wrote in message
news:OI**************@TK2MSFTNGP15.phx.gbl...
J.S.
In addition to the other comments:

It sounds like you are building some type of "Code Generator" where you
have
a template & then insert "variables" into this template. Correct?

I would consider using Xml (not specifically a DataSet) to store the
"template" itself in.

Then I would use System.Xml.XPath namespace to read the "template" & the
System.CodeDom namespace to generate the source file.

In many ways using a DataSet to read the Xml file is both easier & harder
then using an XPathNavigator object (from System.Xml.XPath).

The Xml file could either define the structure of your template directly
(ala XSLT) or it could include snippets of code that you use one of the
CodeSnippet* classes to piece the pieces together. The advantage of using
Xml to define the structure directly is that you could then allow your
code
generator to support languages other then VB, as the template itself would
not have any language (VB, C#) specific constructs in it, it would only
have
abstract Xml constructs. The "variables" that you define would be in a
specific language, however it sounds like your user is typing the values
of
these variables any way.

NOTE: I would use one of the CodeSnippet* classes to inject what the user
is
entering into the generated CodeDom file...

FWIW: ASP.NET, XSD.EXE & WDSL.EXE all use the CodeDom for their code
generation. I understand that VS.NET has its own Code Serializer that may
or
may not leverage the CodeDom.

Alternatively I would consider using either an XSLT to transform the
template & "variables" into a .vb file. In some ways I see XSLT as being
the
"easier" but more "restrictive" approach...

Hope this helps
Jay

"J.S." <js*@nospam.com> wrote in message
news:OC**************@TK2MSFTNGP15.phx.gbl...
| In a Windows Form application, which is the better method to concatenate
| large blocks of code?
|
| 1. Reading the text from text files.
| 2. Adding the text to the VB file itself?
|
| Thanks!
| J.S.
|
| --
|
|

Nov 21 '05 #14
Jay,

From your message (I did not read in once) I got first the idea that it is
a choose between an XML document or an XML dataset (you have not written
that). Therefore as addition it is possible to use the best of both.

In JavaScript I use by instance Msxml2.DOMDocument to read a dataset.

Cor


Nov 21 '05 #15

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: lastusernameleft | last post by:
i've been researching this issue for a while and can't come to any conclusive answer, mostly it seems to be a preference over syntax, some saying c# is elegant while vb is clunky, or that c# is...
14
by: Blue Ocean | last post by:
My c++ text tells me that I should define methods this way: class Stack { int method(double t); Stack(int s); ... } int Stack::method(double t)
106
by: cfmortgagepro | last post by:
Hi, I know that I'm an extreme newb by asking this overly beaten question, but I am leaning toward C#, becuase the perception is that it is better to learn than VB.Net. I guess it makes you...
47
by: Dickson Woo | last post by:
Just that.
9
by: David Helgason | last post by:
I'm calling one stored procedure with a prepared statement on the server with 6 arrays of around 1200 elements each as parameters. The parameters are around 220K in total. This is taking a...
15
by: Rob Meade | last post by:
Hi all, I have a databse which I'm pulling the data from for my ASP page. I have 4 tables, Course, Feature, Objective, and PreRequisite. The last three all contain a course product code and a...
23
by: JoeC | last post by:
I am a self taught programmer and I have figured out most syntax but desigining my programs is a challenge. I realize that there are many ways to design a program but what are some good rules to...
7
by: lister | last post by:
Hi, I have a situation where I have a large block of HTML code that is conditionally displayed. In effect I have: html page some html <?php if (bShowBlock)
1
by: WebCM | last post by:
I'm looking for a good idea or ready library for templates. HTML with PHP isn't the best solution (it's more difficult for end-users of CMS to edit them). Perhaps, everything I need is: -...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.