Solved

PadLeft

Posted on 2004-10-15
13
188 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
  • 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 85

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
Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

 

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 50 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 85

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 85

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 85

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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Well, all of us have seen the multiple EXCEL.EXE's in task manager that won't die even if you call the .close, .dispose methods. Try this method to kill any excels in memory. You can copy the kill function to create a check function and replace the …
Creating an analog clock UserControl seems fairly straight forward.  It is, after all, essentially just a circle with several lines in it!  Two common approaches for rendering an analog clock typically involve either manually calculating points with…
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

856 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