?
Solved

PadLeft

Posted on 2004-10-15
13
Medium Priority
?
199 Views
Last Modified: 2010-04-23
In c# I have the code as follows:
reqn = Session["Reqnumber"].ToString();
reqn = reqn.PadLeft(15,'-');
The value of reqn is never right justified. Please help me.
Thanks
0
Comment
Question by:miyengar
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 7
  • 4
  • 2
13 Comments
 
LVL 28

Expert Comment

by:iboutchkine
ID: 12322307
I thiink you have to assign it to different variable
dim a as string
a= reqn.PadLeft(15,'-');
regn = a
0
 
LVL 86

Expert Comment

by:Mike Tomlinson
ID: 12322557
This worked for me in VB.Net (notice the double quotation marks):

    Dim reqn As String = "something"
    reqn = reqn.PadLeft(15, "-")
    MsgBox(reqn)

~IM
0
 

Author Comment

by:miyengar
ID: 12322708
It does not work. any other soln
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:miyengar
ID: 12323284
reqn = Session["Reqnumber"].ToString();
a = reqn.PadLeft(15,'-');
It returns the value of a as null. Please tell me why?
0
 
LVL 28

Accepted Solution

by:
iboutchkine earned 100 total points
ID: 12323306
Did you check your session value?
0
 

Author Comment

by:miyengar
ID: 12323434
my session value and reqn contains the actual value "wq-01".but "a" still has null
0
 

Author Comment

by:miyengar
ID: 12323496
It does not work properly i have my code as follows:
                           
            private void Page_Load(object sender, System.EventArgs e)
            {
                  
                       string r;
                  string reqn;
                  string rqtextid;
                  reqn = Session["Reqnumber"].ToString();
                  r = reqn.PadLeft(9,'.');
                  rqtextid = r;
my session value has valid value iii0, reqn also has the same value iii0. but r has null.
0
 
LVL 86

Expert Comment

by:Mike Tomlinson
ID: 12323883
Did you actually try it with double quotes?

    r = reqn.PadLeft(9,".");
0
 

Author Comment

by:miyengar
ID: 12337965
using double quotes gives me an error as no overload method as it accepts int and char.
0
 
LVL 86

Expert Comment

by:Mike Tomlinson
ID: 12338715
How odd...it works in VB.Net.  Thought it was supposed to be a "common" language runtime...

~IM
0
 

Author Comment

by:miyengar
ID: 12338827
any other suggestion please
I have the code as
  private void Page_Load(object sender, System.EventArgs e)
          {
               
                     string r;
               string reqn;
               string rqtextid;
               reqn = Session["Reqnumber"].ToString();
               r = reqn.PadLeft(9,'.');
               rqtextid = r;

in the above code r has ----wq001 but in the statement rqtextid  = r, rqtextid  has null.
Please help.
0
 
LVL 86

Expert Comment

by:Mike Tomlinson
ID: 12339300
Have you tried going directly to rqtextid?

    rqtextid = Session["Reqnumber"].ToString().PadLeft(9,'.');

~IM
0
 

Author Comment

by:miyengar
ID: 12339807
I did.  If I have to add text further after rightjustifying it would display null
for ex:
rqtextid = Session["Reqnumber"].ToString().PadLeft(9,'.');
rqtextid += "kkk";
would return rqtextid as null
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The ECB site provides FX rates for major currencies since its inception in 1999 in the form of an XML feed. The files have the following format (reducted for brevity) (CODE) There are three files available HERE (http://www.ecb.europa.eu/stats/exch…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
Suggested Courses
Course of the Month13 days, 16 hours left to enroll

800 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question