473,322 Members | 1,401 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,322 software developers and data experts.

Padright

""NAME","SYSTEM_ID","TAX_ID","LICENSE"";
the Above is one row read in from a text file

its 38 bytes in width i want to pad this to 77
in my code padright is not working correctly unless i string.trimend() the
above row
example

string sRow

sRow = ""NAME","SYSTEM_ID","TAX_ID","LICENSE"";

sRow=sRow.PadRight(77);
Console.Writeline(cRow) ; // ouput is "
ENSE"

//if i trimend this it works
sRow=sRow.TrimEnd();
sRow=sRow.Padright(77);

Console.WriteLine(sRow);

Any thoughts
MJ
Aug 2 '07 #1
3 4348
""NAME","SYSTEM_ID","TAX_ID","LICENSE"";
the Above is one row read in from a text file

its 38 bytes in width i want to pad this to 77
in my code padright is not working correctly unless i string.trimend() the
above row
example
I was able to reproduce the problem in your code with the following
line:
sRow = "\"NAME\",\"SYSTEM_ID\",\"TAX_ID\",\"LICENSE\" \r";

Perhaps you are getting a Carriage Return (\r) and spaces at the end
of your line.

How are you reading in the line from the file?

Aug 2 '07 #2
just found it....yep there was a embedded \r
in each string

Thanks
MJ
just love reading binary files
lol

"Mark Peters" <mp*******@gmail.comwrote in message
news:11**********************@j4g2000prf.googlegro ups.com...
>""NAME","SYSTEM_ID","TAX_ID","LICENSE"";
the Above is one row read in from a text file

its 38 bytes in width i want to pad this to 77
in my code padright is not working correctly unless i string.trimend()
the
above row
example

I was able to reproduce the problem in your code with the following
line:
sRow = "\"NAME\",\"SYSTEM_ID\",\"TAX_ID\",\"LICENSE\" \r";

Perhaps you are getting a Carriage Return (\r) and spaces at the end
of your line.

How are you reading in the line from the file?

Aug 2 '07 #3
MikeJ <ve***********@sbcglobal.netwrote:
""NAME","SYSTEM_ID","TAX_ID","LICENSE"";
the Above is one row read in from a text file

its 38 bytes in width i want to pad this to 77
in my code padright is not working correctly unless i string.trimend() the
above row
example

string sRow

sRow = ""NAME","SYSTEM_ID","TAX_ID","LICENSE"";

sRow=sRow.PadRight(77);
Console.Writeline(cRow) ; // ouput is "
ENSE"

//if i trimend this it works
sRow=sRow.TrimEnd();
sRow=sRow.Padright(77);

Console.WriteLine(sRow);

Any thoughts
Could you post a short but complete program which demonstrates the
problem?

See http://www.pobox.com/~skeet/csharp/complete.html for details of
what I mean by that.

(In particular, the assignment to sRow doesn't compile at the moment -
it isn't valid C#.)

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too
Aug 2 '07 #4

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

Similar topics

1
by: john sutor | last post by:
Is there something wrogn with this syntax? It does not put in the padded characters. string hk="Assembly"; hk.PadRight(35,'-'); this.textBox1.Text=hk + "Test"; The output is AssemblyTest
1
by: jimmy chao via .NET 247 | last post by:
Hi I am having problems with using the padright function in ASP.NET. my code is string listring; string strTitle = ds.Tables.Rows.ToString().Trim(); if (strTitle.Length > 15) { strTitle =...
3
by: John A Grandy | last post by:
what's the best way in VB.NET to build a string as a concatenation of a certain number of characters ? for example, 25 "*" characters : "*************************"
2
by: Bill Nguyen | last post by:
I tried in vain to add blank space to the end of couple variables as below: mPadding = Convert.ToChar(" ") mdriverBegin.PadRight(16, mPadding) mdriverEnd.PadRight(16, mPadding) ...
20
by: djc | last post by:
I get this *intermittently* on a utility I am working on. I don't know whats going on but here are a few points about it: - using VS 2005, running on xp sp2 - program uses multiple threadpool...
2
by: lmnorms1 | last post by:
Hello, I am looking to update a record that was read in with OleDbDataReader. I have the record in reader but now with the reader connection open; how do I update it. Any advice would be...
4
by: Pascal | last post by:
hello i try to use padright and padleft to beautify the aspect of my prints. I 'd like the text to be print in two columns but i don't know the size of each string before (because they are...
0
by: Paul Ilacqua | last post by:
I'm using VB .NET and I'm trying to "roll my own" report subtotals. I'm building a string from a datareader top pass to a reporting class and I want to break and subtotal QTY at each change in...
2
by: akshaycjoshi | last post by:
Refer the pic below, It's showing properly when seen in notepad but not in combobox. Here is the code OleDbDataReader trunkdr = trunkcom.ExecuteReader(); while (trunkdr.Read()) {...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...

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.