473,399 Members | 3,603 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,399 software developers and data experts.

vb.net code for inserting vbcrlf every 80 characters

Here's the thing. I am downloading a tiff image through an http
stream, then I am converting it to a byte array, then I convert it to a
string which I place in an XML file. When I place the string in the
xml file it is super long (slows down all editors when opening), so I
was thinking to insert vbCrLf every 80 characters or so but I don't
want to slow down my program that creates the XML file. I was
wondering the best way to accomplish that. Here is my current code:

xmlWriter.WriteString(getBase64Document(loan))

Private Function getBase64Document(ByVal loan As MtgLoan) As String
Dim httpStream As System.Net.WebClient = New Net.WebClient()
Dim bytes As Byte() =
httpStream.DownloadData(loan.ICMBASE(0).resourceOb ject.URL.value) 'This
pulls in the image as a byte()
Dim base64String As String = Convert.ToBase64String(bytes)

Return base64String
End Function

Sep 8 '06 #1
3 2639
Tom,

I'm more C# than VB... but I did do a lot of VB6 so I'll just wing it
(strings in vb.net begin at 0... right?):

Dim i as Integer
Dim f as String

f = ""
For i = 0 to len(Base64String) - 1 step 80 :
f = f & mid(Base64String, i, 80) & vbCrLf
Next i
Regards,

Rob

<to*******@gbmail.comwrote in message
news:11*********************@b28g2000cwb.googlegro ups.com...
Here's the thing. I am downloading a tiff image through an http
stream, then I am converting it to a byte array, then I convert it to a
string which I place in an XML file. When I place the string in the
xml file it is super long (slows down all editors when opening), so I
was thinking to insert vbCrLf every 80 characters or so but I don't
want to slow down my program that creates the XML file. I was
wondering the best way to accomplish that. Here is my current code:

xmlWriter.WriteString(getBase64Document(loan))

Private Function getBase64Document(ByVal loan As MtgLoan) As String
Dim httpStream As System.Net.WebClient = New Net.WebClient()
Dim bytes As Byte() =
httpStream.DownloadData(loan.ICMBASE(0).resourceOb ject.URL.value) 'This
pulls in the image as a byte()
Dim base64String As String = Convert.ToBase64String(bytes)

Return base64String
End Function

Sep 9 '06 #2
Tom,

My previous message... I was doing simple concatenation... "f = f & mid(f,
...) & f"... well that really should be done using a string builder. String
builder is much more efficient than regular strings for this exact sort of
algorithm.

Doh!!

Regards,

Rob
<to*******@gbmail.comwrote in message
news:11*********************@b28g2000cwb.googlegro ups.com...
Here's the thing. I am downloading a tiff image through an http
stream, then I am converting it to a byte array, then I convert it to a
string which I place in an XML file. When I place the string in the
xml file it is super long (slows down all editors when opening), so I
was thinking to insert vbCrLf every 80 characters or so but I don't
want to slow down my program that creates the XML file. I was
wondering the best way to accomplish that. Here is my current code:

xmlWriter.WriteString(getBase64Document(loan))

Private Function getBase64Document(ByVal loan As MtgLoan) As String
Dim httpStream As System.Net.WebClient = New Net.WebClient()
Dim bytes As Byte() =
httpStream.DownloadData(loan.ICMBASE(0).resourceOb ject.URL.value) 'This
pulls in the image as a byte()
Dim base64String As String = Convert.ToBase64String(bytes)

Return base64String
End Function

Sep 9 '06 #3
tom
Okay I actually changed my code so that it processes even quicker now.
I would still like vbCrLf every 80 characters or so, and I tried a
couple methods and they are super slow. Any other ideas on a quick
running solution? Here is the code I use now...
Dim httpStream as system.net.webclient = new net.webclient()
dim bytes as byte() =
httpstream.downloaddata(loan.icmbase(0).resourceob ject.URL.value)
xmlWriter.WriteBase64(bytes, 0, bytes.Length)

So now instead of sticking it in a string I buffer it from bytes
straight to file.

Rob MacFadyen wrote:
Tom,

My previous message... I was doing simple concatenation... "f = f & mid(f,
..) & f"... well that really should be done using a string builder. String
builder is much more efficient than regular strings for this exact sort of
algorithm.

Doh!!

Regards,

Rob
<to*******@gbmail.comwrote in message
news:11*********************@b28g2000cwb.googlegro ups.com...
Here's the thing. I am downloading a tiff image through an http
stream, then I am converting it to a byte array, then I convert it to a
string which I place in an XML file. When I place the string in the
xml file it is super long (slows down all editors when opening), so I
was thinking to insert vbCrLf every 80 characters or so but I don't
want to slow down my program that creates the XML file. I was
wondering the best way to accomplish that. Here is my current code:

xmlWriter.WriteString(getBase64Document(loan))

Private Function getBase64Document(ByVal loan As MtgLoan) As String
Dim httpStream As System.Net.WebClient = New Net.WebClient()
Dim bytes As Byte() =
httpStream.DownloadData(loan.ICMBASE(0).resourceOb ject.URL.value) 'This
pulls in the image as a byte()
Dim base64String As String = Convert.ToBase64String(bytes)

Return base64String
End Function
Sep 19 '06 #4

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

Similar topics

7
by: Jason | last post by:
When users fill out my text area field, there is a chance that there will be no line feeds or cariage returns or spaces and just one really long word. THIS CAUSES A MAJOR PROBLEM! What I am trying...
4
by: techy techno | last post by:
Hii I am trying to write down a cdont aplication which will email the survey form to the TO address with the answers checked by the user using the survey form I am 100% sure that there is...
9
by: Steve Jorgensen | last post by:
First, an example - today, I wanted to print out the parameter values in a querydef object at a break point in the code for subsequent manual debugging of the query. In the past, I would have had...
6
by: Jurjen de Groot | last post by:
I want to show a variable length field within a cell in a table. <TD> ....here... </TD> I'm not sure how to do that, the information is stored in a class property Org.CVtext I can't use a...
18
by: Joe Fallon | last post by:
I have some complex logic which is fairly simply to build up into a string. I needed a way to Eval this string and return a Boolean result. This code works fine to achieve that goal. My...
5
by: Drygast | last post by:
I've got at form where I insert some information to a string ( oMed ) using a inputbox. I would like to alter the string so that a vbcrlf is inserted into the string every 50 charachters or so....
1
by: Ken Fine | last post by:
I'm using ASP VB. I want to insert a VbCr or a VbLf into a declared string every N characters. FWIW, I want to do this because of an apparent limitation in MSXML2, which I am using to "scrape" data...
1
by: Eric | last post by:
When I run my script it gives error on the following line: strEmail = Right(strEmail, (Len(strEmail) - 1)) I enclose my code and the sample text file too Thanks,...
2
by: kevtek | last post by:
I have one 20 byte field in an access database. I want to break up the data by inserting a "-" after every 2 characters in the field. Some records might only be 2 characters long, some six or even...
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
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
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...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.