Solved

PadLeft

Posted on 2004-10-15
13
183 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
 

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
Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

 

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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Parsing a CSV file is a task that we are confronted with regularly, and although there are a vast number of means to do this, as a newbie, the field can be confusing and the tools can seem complex. A simple solution to parsing a customized CSV fi…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

705 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

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now