Formatting a string

Hello All
Is there a way I can use format specifiers with variables?
OK so I need to format a string to be a certain length equal to the longest string I am using. So what I would like to use is something like:
%xs where x is the number of the length of the longest string I have. So if I have a string with 9 characters and one with 4 characters then I need 5 spaces on the left side of the 4 character string to push it to the right. (5 = 9 - 4). But the 9 might become 12 one time, or 3 the other, so it is a variable length.
I tried to use concatenation to build the formatter expression, but the printf line did not understand it.
Any help would be greatly appreciated.

Well I can think of two solutions...
If you want to not modify the Strings and just show the outcomes of adding the spaced you can simply print the appropriate amount of spaces before the string...
public class Sandbox {
     public static void main(String[] arg)     {
          String s1 = new String("Hello World");
          String s2 = new String("Hello");
          System.out.println(s1);
          for (int x=0; x<(s1.length() - s2.length()); x++) {
               System.out.print(" ");
          System.out.print(s2);
OUTCOME:
Hello World
      HelloBut if you want to actually make the string that certain amount of spaces longer you can use the following...
import java.lang.StringBuilder;
public class Sandbox2 {
     public static void main(String[] args) {
          String s1 = new String("Hello World");
          String s2 = new String("Hello");
          StringBuilder sb = new StringBuilder(s2);
          for (int x=0; x<(s1.length() - s2.length()); x++) {
               sb.insert(0, " ");
          System.out.println(s1+"\n"+sb);
OUTCOME:
Hello World
      Hello

Similar Messages

  • Can anyone answer this question? What is used to format a string so that it falls into a certain Row/Column in excel? see text for indepth question.

    I'm attaching a file that may help. Just remember this is my FIRST attempt at using NI/FeildPoint so things that would be obvious to the normal users more than likely would slide right by me. So I'll try and explain what the text contains as to make my problem more clear. I'm using a FP-1000, FP-AI-100, and a FP-TB-10. i'm creating a application where I'm using the 8 channels from the FP-AI-100 to monitor a control system ,that we manufacture. The control system is in an environmental chamber. I use the FP-TB-10 to monitor the temperature while in the chamber. The control system is ran for 4 hours under varing enviromental conditions while I monitor vital system voltages with the FP-AI-100. Now the application that i'm building starts with the obvious FP CREATE.VI and so forth I have no problem communicating with the FP's, but the information that I'm monitioring needs to be placed into a file with Headers describing the information below it. Now I use a "WHILE LOOP.VI" to monitor the FP-AI-100 & FP-TB-10 for the 4 hour period. but before that I create and open a file where I use a "CONCATENATE STRINGS.VI" to enter the headers I need. I do this by CONSTANTS, CONTROLS, TABs, AND CARRIAGE RETURN being entered into the "CONCATENATE STRINGS.VI" in the order I want them to appear. I use ROW 1 to enter (OPERATOR:with a CONSTANT) an a (CONTROL so the operator may enter his name and be recorded into the file) using a TAB to seperate Columns and a CARRIAGE RETURNto drop down to ROW 2 for the next headers. I use header names and TABs to seperate the columns. This part works great. I end up with ROW 1 having the operator information then ROW 2 having the headers for all the channels I'm using to monitor the control system with in their own column. The trouble happens when I write to this file during the "WHILE LOOP". The information recorded for DATE:, TIME:, and Channel 0 of the FP-AI-100 end up right under their corresponding header on ROW 3, but the rest of the data ends up on ROW 4 in column 3 and goes down many rows with some of the data not being stored at all. It varies on how many rows are used starting at ROW 4 but hey always stay in column 3. I use the "FP READ.VI" outputing to a "ARRAY TO SPREADSHEET STRING.VI" outputing to a "CONCATENATE STRINGS.VI" for each channel within the "WHILE LOOP" then into the "WRITE.VI". I use the "CONCATENATE STRINGS.VI" to place my data OR atleast I thought you could do that some how I'm not quit doing something write either there is a sampling/timing issue or writing to file issue where things are being confused in the "WHILE LOOP" if someone know a better route to perform what I'm tring here I would be interested. Its not like I'm not giving it the old colledge try here but without proper training and the vagness of the manuals it's difficult to understand what every connection actually does.I'm tring though for everyone who happens to fill pity for me
    Thanks for your help
    John Morris
    Glendinning Marine Product, Inc.
    Attachments:
    ALLchannels ‏273 KB

    > I appreciate your effort to help me, but there is still a slight cloud
    > in front of my eyes here.(I must mention that I'm using Labview 5.1
    Oh, to bad. I'm using LV 6,02 and tried to save the application as LV5.1,
    but it didn't work.
    > Lets start with the easy one which is the SECOND main thing you
    > wanted to mention. In my application I used individual Create Tag.vi's
    > "so your saying that I can use just one Create Tag.vi and one Read.vi
    > and what ever I use to display the values will automatically to show
    > the individual channels" in other words if I use a "Indicator(DBL)"
    > comming out of the Read.vi what ever I use in the "PANEL" layout will
    > expand to show all 8 channel if I was using a FP-AI-100? Cool...
    Allmost right. The 8 channels come out as 1D-array, ch0...ch7.
    > #1--How do I change the delimiter (TAB) to a delimiter (comma) in a
    > Array to Spreadsheet String.vi?
    > ...cut
    I don't use this Spreadsheet VI, because files coming out there allways
    start this time consuming EXCEL wizzard. Because of this, I programmed my
    own CSV-conversion vi. Maybe you could just use a common texteditor, like
    wordpad and put the csv-examples from my last reply down to a text file
    and rename it to *.csv. Texteditors terminate lines with "\r\n" by
    default, so this is a very quick way for testing.
    > FP_Analog_Logging example to record all eight channels it uses a Array
    I didn't find the vi you metione above, but there is another good one:
    Look at examples\FieldPoint\DataLogging\FP Logger.vi.
    In a little case structure, at "false", there is a function called "Format
    into string".
    Pop up on the format string and adjust >>'\' Codes Display<<.
    Then you change the format string into: %.;%-f%s
    A Tab string is connected to the lower input of this function. Replace
    this one with a comma.
    That should do.
    >
    > #2--If using just one Create Tag.vi and one Read.vi and I have the
    > Item Name listed as ALL I take it that the information comming out of
    > the Read.vi is data for each channel in a String format starting with
    > channel 0 and ending with channel 7 for the FP-AI-100.
    Yes, just as explained above. If you put a indicator at the output to
    display the values, you can expand the display to show all 8 channels, but
    you can't name induvidual cells. In a array, all cells have identical
    named labels. If you want to name the individually, you have to attach the
    array to cluster function and put the indicator after this one. Enable
    labe display and name the output values individually.
    > #3--Now I use the following to "Format String" in the Array to
    > Spreadsheet string.vi (%.4f)but I don't see anyway of changing the
    > delimiter from (TAB) to (COMA)
    Explained above.
    > #4 you stated text strings need a "as prefix and sufix" and each
    > string is seperated by a coma, a period is used as decimal number
    > separator and lines have to be terminated by my question is
    > WHERE IS THIS ACCOMPLISHED? WHAT VI OR WHAT CONNECTOR PIN?
    Well, modifying strings are done with string functions.
    Above, as I explained how the sample FP Logger.vi can be modified to do
    the job for numbers. The pre- and suffixing with ", you only need for
    strings, which EXCEL should interpret a string and as nothing else as a
    string, even if there's a number inside. You usually need this only for
    headers. So its easyest, if you just write your string into a string
    constant or control and concatenate it to the previous csv-file contents.
    Oh, I just see by looking at the above mentioned example... Inside the
    case structure, but in the "true" case, there are error messages
    concatenated to the logfile. At this point it is importent, to use " for
    integrating the message into the CSV file, because a error message usually
    looks like this: >> ERROR 2345 in vi yxz <<
    Here you have text and number strings mixed in one line. EXCEL does not
    know, if it should interpret the number inside the error line as separate
    number, separating the line into three colums i.e. string before number,
    number and string after number. So tell EXCEL by putting a " before and
    after the line each.
    For this, expand the Format To String function by one input, move down all
    connections, to be able to insert a string constant with a " to the first
    argument connector. Change the contents of the string constant at the
    bottom argument from tab to ", (quotation mark AND comma)
    > #5 You gave me an example of what a 3 column header could look like:
    > "col0","col1","col2"\r\n Now is this something that you enter
    > somewhere cause I know that \r is carriage return and \n is newline so
    > I take it that the above is entered somewhere maybe in the Write.vi to
    > the connector called Header (F)? See this is what confuses me because
    > NI manuals have no examples of certain connectors types being used or
    > any reference as to how they manipluate data with there varing type
    > inputs. Or maybe I'm just missing them.
    The example I mentioned above help here to.
    Look at the Write File function. This function receves data from a
    function named concatenate strings. Expand this function to have one more
    spare input at the bottom. Create a string constant. Switch the constant
    display to "\" mode. Enter "col0","col1","col2"\r\n into the constant.
    Connect the constant to the spare input.
    Doing this, every dataline in the csv file is followed by
    "col0","col1","col2"\r\n .
    I wish you a nice weekend,
    Rainer Ehrt

  • Formatting a string with time stamp and double precision numbers

    %s\t%f\r%f
    This is a format string that I have in old code that I've decided to change.  Problem is I cannot make sense of the string codes in my own old code! Let me explain what I want, and hopefully someone can explain how to do it.
    I am using the format into string subvi to merge a time stamp (formatted as %m%d%Y%H%M%S%5u) and two different double precision numbers.  This string is then wired into the Write Characters to File subvi so that I can record data as a .txt file, and open it in either Matlab or Excel.  There is a minor problem with the string format above because in excel the first time stamp entry is blank, and the first loop only gives the two double precision numbers withouth the time stamp - the time stamp appears in the next loop (probably a looping issue and not due to the string format, but if you see differently please let me know).  Now what I want to do is 1. potentially fix that problem and 2. add some more doubles. 
    1. Is there a string format issue that is evident that I am not seeing that causes the time stamp to be formatted into the string after a carriage return?  Or should I be looking at looping issues?
    2. How do I add another one - three floating point numbers (double precision)?  Are the \'s marking different numbers in this string constant?  Or is it the %?  I can't find any information about the \'s, but I see that % begins the format specifier. 
    Ideally, I want these data in the following columns:  Date, Time(absolute), FP, FP, FP, carriage return for the next loop (FP is floating point double precision number).
    Thanks,
    Brad

    Hi JonN,
    Here there is no need of string concordinate function (in your code), the same result you can find if you connect the output of the format string to shift register, and shift register in data to initialize string connector in format into string function.
    <<KUDOS ARE WELCOME>>
    ELECTRO SAM
    For God so loved the world that he gave his one and only Son, that whoever believes in him shall not perish but have eternal life.
    - John 3:16

  • Formatting a string in message mapping

    Hi all,
           This is about Formatting a String. I have seen a NumberFormat( arithmetic ) for numbers. Is there any function for String Format? For my application, I need to append empty string at right side of the input string. This string may be varying its length.  If standard function not exits then please help me with USD

    Hi,
    Do u mean to say that the target field is of fixed length and source field may b of varying length.
    Hence depending on the strlen() of the source field you need to keep append empty strings to reach the length of the target field?
    Arvind

  • Exchange 2010, khi: failed to execute Troubleshoot-DatabaseSpace.ps1 Error formatting a string: Format string is not supported

    Hi,
    Exchange 2010 MP fails to run Troubleshoot-DatabaseSpace.ps1. Results in a Warning with "Error formatting a string: Format string is not supported". The EventNumber is 402. The Microsoft article it points to is useless at http://technet.microsoft.com/en-us/library/749e0eac-ebb2-41e3-8fa2-4a03a1bd3571.aspx 
    Run ".\Troubleshoot-DatabaseSpace.ps1 -Server MailboxServer.domain.com -MonitoringContext" and works fine.
    Any help appreciated.
    thanks

    Hi,
    Before the newer MP release, we can disable  these 4 monitor via override and this should not run the Troubleshoot-DatabaseSpace.ps1 :
    KHI: Failed to execute Troubleshoot-DatabaseSpace.ps1.
    KHI: The database copy is low on database volume space and continues to grow. The volume is under 25% free
    KHI: The database copy is low on database volume space and continues to grow. The volume has reached error levels under 16% free.
    KHI: The database copy is low on database volume space and continues to grow. The volume has reached critical levels 8% free.
    Alex Zhao
    TechNet Community Support

  • Method to Format a string column containing HTML tags as simple string.

    Hello,
    I am working with formating a string column which holds Html tags.
    I want to remove these tags from the actual data which has to be shown on the BI Publisher report.
    Can you suggest how can we format this in the DataSet designer of BI publisher so that my data is recognised on the Layout designer.
    I have been trying to create an expression using the "Add Element by Expression" option to format this html tag data as normal string without the tags.
    Can you suggest if this is the correct method to do this.
    I found this below code being used in an existing DateSet but i am not able to recreate a similar formating on this kind of data column.
    <![CDATA' || '['|| TO_CLOB(SUCCESS_CRITERIA) || ']' || ']>
    Kindly suggest if you have any idea on the above mentioned issue.
    Thanks,
    Shweta

    And read this:
    Navigate yourself around pitfalls related to the Runtime.exec() method
    http://www.javaworld.com/javaworld/jw-12-2000/jw-1229-traps.html

  • How to format paragraph string to show content left, Right or middle of pdf document using iTextsharp ' vb

    Dear All
    how to format paragraph string to show content left, Right or middle of pdf document using iTextsharp in visual basic and absolute position on the document.
    Thanks

     Here is one more example that i have modified the GetCell function so that you can use it for adding all the cells to the document.  It takes several arguments to specify everything you need to create each cell.  It now lets
    you specify the Text, the Text Alignment, the Text Font and color, weather the cell shows the Border, the BackColor of the cell, and the Padding values for the Left, Right, Top, and Bottom.
     If you study the code you should be able to figure out how it works.  From here you can figure out the rest of what you need to do and how to use the
    GetCell function.
     With one quick google search for "iTextSharp Documentation" the first link to pop up was this link.
    iTextSharp Documentation
    Imports System.IO
    Imports Its = iTextSharp.text
    Public Class Form1
    Private dt As New DataTable
    Private Sub Form1_FormClosing(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing
    dt.Dispose()
    End Sub
    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    dt.Columns.Add("Name")
    dt.Columns.Add("Age")
    dt.Columns.Add("Birth Date")
    dt.Rows.Add(New Object() {"Johnny", "23", Now.AddYears(-23).ToString})
    dt.Rows.Add(New Object() {"Frank", "41", Now.AddYears(-41).ToString})
    dt.Rows.Add(New Object() {"Rex", "33", Now.AddYears(-33).ToString})
    dt.Rows.Add(New Object() {"Kim", "26", Now.AddYears(-26).ToString})
    End Sub
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
    Dim MyPdfFilePath As String = "C:\TestFolder\MyPdf.pdf"
    Dim pSize As New Its.Rectangle(Its.PageSize.A4)
    Dim PdfDoc As Its.Document = New Its.Document(pSize, 10, 10, 10, 10)
    Dim PdfImage As New Its.Jpeg(New Uri("C:\TestFolder\MyLogo.jpg"))
    PdfImage.Alignment = Its.Jpeg.ALIGN_CENTER
    Dim pTable As New Its.pdf.PdfPTable(1)
    pTable.AddCell(getCell("Name : " & TextBox1.Text, Its.pdf.PdfPCell.ALIGN_CENTER, Its.FontFactory.GetFont("Arial", 15, Its.BaseColor.BLACK), False, Its.BaseColor.WHITE, 10, 0, 0, 0))
    pTable.AddCell(getCell("Policy : " & TextBox2.Text, Its.pdf.PdfPCell.ALIGN_CENTER, Its.FontFactory.GetFont("Arial", 20, Its.BaseColor.RED), False, Its.BaseColor.WHITE, 10, 20, 0, 0))
    Dim cTable As New Its.pdf.PdfPTable(dt.Columns.Count)
    For Each col As DataColumn In dt.Columns
    cTable.AddCell(getCell(col.ColumnName, Its.pdf.PdfPCell.ALIGN_CENTER, Its.FontFactory.GetFont("Arial", 12, Its.BaseColor.WHITE), True, Its.BaseColor.BLUE, 3, 5, 0, 0))
    Next
    Dim tblfont As Its.Font = Its.FontFactory.GetFont("Arial", 10, Its.BaseColor.BLACK)
    For Each row As DataRow In dt.Rows
    cTable.AddCell(getCell(row.Field(Of String)("Name"), Its.pdf.PdfPCell.ALIGN_LEFT, tblfont, True, Its.BaseColor.WHITE, 3, 4, 3, 0))
    cTable.AddCell(getCell(row.Field(Of String)("Age"), Its.pdf.PdfPCell.ALIGN_CENTER, tblfont, True, Its.BaseColor.WHITE, 3, 4, 0, 0))
    cTable.AddCell(getCell(row.Field(Of String)("Birth Date"), Its.pdf.PdfPCell.ALIGN_RIGHT, tblfont, True, Its.BaseColor.WHITE, 3, 4, 0, 3))
    Next
    Using fs As New FileStream(MyPdfFilePath, FileMode.Create, FileAccess.Write, FileShare.None)
    Using pdfWrite As Its.pdf.PdfWriter = Its.pdf.PdfWriter.GetInstance(PdfDoc, fs)
    PdfDoc.Open()
    PdfDoc.Add(PdfImage)
    PdfDoc.Add(pTable)
    PdfDoc.Add(cTable)
    PdfDoc.Close()
    End Using
    End Using
    PdfDoc.Dispose()
    End Sub
    ''' <summary>Creates a new cell for the table.</summary>
    ''' <param name="text">The text string for the cell.</param>
    ''' <param name="alignment">Alighnment for the text string.</param>
    ''' <param name="textfont">The font used for the text string.</param>
    ''' <param name="border">True to show the cell border. False to hide the cell border.</param>
    ''' <param name="backcolor">The background color of the cell.</param>
    ''' <param name="padtop">The amount of padding on the top of the text string.</param>
    ''' <param name="padbottom">The amount of padding on the bottom of the text string.</param>
    ''' <param name="padleft">The amount of padding on the left of the text string.</param>
    ''' <param name="padright">The amount of padding on the right of the text string.</param>
    Public Function getCell(ByVal text As String, ByVal alignment As Integer, ByVal textfont As Its.Font, ByVal border As Boolean, ByVal backcolor As Its.BaseColor, ByVal padtop As Single, ByVal padbottom As Single, ByVal padleft As Single, ByVal padright As Single) As Its.pdf.PdfPCell
    Dim cell As New Its.pdf.PdfPCell(New Its.Phrase(text, textfont))
    cell.BackgroundColor = backcolor
    cell.PaddingLeft = padleft
    cell.PaddingRight = padright
    cell.PaddingTop = padtop
    cell.PaddingBottom = padbottom
    cell.HorizontalAlignment = alignment
    If Not border Then cell.Border = Its.pdf.PdfPCell.NO_BORDER
    Return cell
    End Function
    End Class
    If you say it can`t be done then i`ll try it

  • Format into string 16 bit signed integer

    Is there any format specifier string for "Format into string", whereas the result is an I16 string?
    My problem is when I use "%d" and the input string is 65535, the result string should be "-1".
    Solved!
    Go to Solution.

    Are you trying to get an integer out of an ASCII string (Scan from String) or turn an integer into a string (Format into String).  You title and question seem to contradict each other.
    Assuming you are trying to scan from string, it looks like you need to scan into a U16 and then use a conversion bullet to turn it into an I16.
    There are only two ways to tell somebody thanks: Kudos and Marked Solutions
    Unofficial Forum Rules and Guidelines
    Attachments:
    Scan I16.png ‏11 KB

  • Format large string for mysql

    I am reading a large txt file that contains sigle quotes and double quotes... I want to format the string and send it to a blob cell in mysql. I need to add an escaoe character before single quotes and double quotes. Any suggestions?

    john joe wrote:
    I am reading a large txt file that contains sigle quotes and double quotes... I want to format the string and send it to a blob cell in mysql. I need to add an escaoe character before single quotes and double quotes. Any suggestions?
    Yes!  Use "Search and Replace String" with "replace all?" = True.  Replace "'" with "\'" and replace """ with "\"".
    Cheers.
    Message Edited by tbd on 02-12-2007 11:06 PM
    "Inside every large program is a small program struggling to get out." (attributed to Tony Hoare)

  • Format Into String

    Hello all,
    I would like to format a string with "a white space" between each
    string member. i am at odds as for the format, for the "format
    string" in the Format Into String function. let me rephrase that...
    the format which needs to be used to format the "FORMAT STRING" in the
    Format Into String function.
    i looked at the help, but it seemed very nebulous to me. all i need is
    to have "a white space" or a "carriage return" between the string
    members and store it to a file.
    thank you,
    cheers,
    -U

    > I would like to format a string with "a white space" between each
    > string member. i am at odds as for the format, for the "format
    > string" in the Format Into String function. let me rephrase that...
    > the format which needs to be used to format the "FORMAT STRING" in the
    > Format Into String function.
    >
    > i looked at the help, but it seemed very nebulous to me. all i need is
    > to have "a white space" or a "carriage return" between the string
    > members and store it to a file.
    >
    The format string is basically what ANSI C uses, but that string
    function has a dialog to help you build it. Either double click the
    node or right click and use the last item.
    In the dialog, you can place a format string followed by an exact string
    followed by another format
    string. For the exact string you can enter a
    space to output a white space, but to do a carriage return you have to
    use a \n or \r.
    Another way to do this, which I think is much easier and easier to read,
    is to use the Concatonate Strings node with three inputs. To the top
    wire the first string, to the middle wire a string constant from the
    next to last row. This is a much cleaner way to do the constants. And
    on the bottom input put the other string.
    Format into String is much more powerful when appending many types of
    data, but the simple append is clearer when it is powerful enough.
    Greg McKaskle

  • How not to omit leading binary zeros with format into string

    I'm using format into string to format serial data .  The problem I'm having is that Format into String with "%b" format identifier omits leading zeros
    in the string..   ie...  "3" becomes "11" when I need it as "0011"
    Solved!
    Go to Solution.

    see figure:
    Attachments:
    Example_VI.png ‏3 KB

  • How to use MD5 format of string

    i want to change a password string to md5 format
    how can i do it

    http://www.twmacinta.com/myjava/fast_md5.php

  • Formatting incoming string with date/time classes?

    Hello,
    In the software I am writing currently I am @ a certain point talking to an external device. sending requests, receiving responses.
    One of the things I find in the response is "20090429094222", as a string.
    I cannot change anything to that, thats the way I get it from the device, so thats where I'll have to start with.
    As you could probably guess this is a date and a time. Now my question. Is there a good way to format this from 20090429094222
    to
    2009-04-29 09:42:22
    using date and or time classes, not using String operations?
    Thanks in advance.

    I found a class containing 2 functions who do exactly what I need, for those intrested:
    public static Date convertStringToDate(String txtFormat, String txtDate) {
            DateFormat dateFormat = new SimpleDateFormat(txtFormat);
            Date date =  dateFormat.parse(txtDate);
            return date;
    public static String formatDate(Date date, String txtFormat) {
            DateFormat dateFormat = new SimpleDateFormat(txtFormat);
            String txtDate = dateFormat.format(date);
            return txtDate;
        }Using them this way gives me exactly what I want:
    Date dt = DateUtil.convertStringToDate("yyyyMMddHHmmss", incomingDateSTring);
    String newDateString = DateUtil.formatDate(dt, "yyyy-MM-dd HH:mm:ss");Problem solved, thanks alot to those who gave me some explanation on the problem.

  • Formatting a string and number?

    I have a to use the method toString() which calls getPay(). getPay() gives a double value of the employee pay. This is what I have for the toString() method:
    abstract class Employee{
    private String name;
    private double pay;
    Employee(String n)
    name=n;
    public double getPay()
    return pay;
    public String toString()
    double amount = getPay();
    return format("Employee Name: %s\n Employee Pay: %.2f",name,amount);
    }I have looked all over google and the syntax that I am using seems to be right. I have even tried putting name and amount in an object and eclipse still throws a fit with the format method. Any ideas?

    Should I create an object array with the values of
    name and amount? And then use that as the argument
    for format?I believe the API docs for String, the varargs intro I linked, and trying it for yourself will answer the question.
    I'm not trying to be an asshole, really. I'm trying to get you to realize that you can find these kinds of answers on your own. Once you get used to that idea, you'll thank me for it. :-)
    Seriously: Read the docs, figure out what you think they mean, write some code based on the assumption that you're right, and see what happens. Repeat. Once you hit a brick wall that way and run out of ideas, post again.

  • Formatting a string with Display String

    I have a field in my database that is a string with numbers in it and I need it formatted like so: "xx-xx-xx-xxx" nine characters long.
    For example: 92438014
    I need it to look like: 09-24-38-014
    and
    141234892
    14-12-34-892 etc..
    can anyone help me with some code that will do this for me? I'm not the best at crystal custom formatting.
    thank you
    Edited by: MarcieHennessy on Oct 14, 2009 10:47 PM

    Raghavendra.G
    I was on this site searching for an answer to my problem, and you provided the solution for me with your response to the above.  However, my problem was a bit different.  I needed a way to format a 9-digit number string into a standard Social Security number format.  I used your formula from above, and WOW - it worked!  If I could award you double Forum Points, I would.  But, since I can't do that, I will just say thanks, and ask God to bless you profusely.
    Kathryn J. Ryan.

Maybe you are looking for