String Alignment problem

Discussion in 'ASP .Net' started by Rahul, Jun 4, 2007.

  1. Rahul

    Rahul Guest

    Friends,

    My Problem is related to writing a text file from a database
    using .Net. in a particular string format.
    I have a dataset with a table, let suppose in this table there are
    three fields.
    - Code
    - Description
    - Amount

    At the time of writing a text file I use in a for loop -

    String.Format("{0,10}{1, 40} {2,-10}", DS.Table(0).Row(i)
    ("Code").ToString(), DS.Table(0).Row(i)("Description").ToString(),
    DS.Table(0).Row(i)("Amount").ToString())


    But the problem is related to the alignment. Data comes like in
    following format:

    01Code 01Desc 2000
    02Code 02Desc 3000
    03CodeABC 03Desc 4000
    04xyz 04Desc 5000


    I want Data comes in following proper alignment format.

    01Code 01Desc 2000
    02Code 02Desc 3000
    03CodeABC 03Desc 4000
    04xyz 04Desc 5000


    So anybody knows the solutions of this problem, please and please
    reply imediately, its urgent.



    Rahul
    Rahul, Jun 4, 2007
    #1
    1. Advertising

  2. Rahul

    GeezerButler Guest

    On Jun 4, 10:08 am, Rahul <> wrote:
    > Friends,
    >
    > My Problem is related to writing a text file from a database
    > using .Net. in a particular string format.
    > I have a dataset with a table, let suppose in this table there are
    > three fields.
    > - Code
    > - Description
    > - Amount
    >
    > At the time of writing a text file I use in a for loop -
    >
    > String.Format("{0,10}{1, 40} {2,-10}", DS.Table(0).Row(i)
    > ("Code").ToString(), DS.Table(0).Row(i)("Description").ToString(),
    > DS.Table(0).Row(i)("Amount").ToString())
    >
    > But the problem is related to the alignment. Data comes like in
    > following format:
    >
    > 01Code 01Desc 2000
    > 02Code 02Desc 3000
    > 03CodeABC 03Desc 4000
    > 04xyz 04Desc 5000
    >
    > I want Data comes in following proper alignment format.
    >
    > 01Code 01Desc 2000
    > 02Code 02Desc 3000
    > 03CodeABC 03Desc 4000
    > 04xyz 04Desc 5000
    >
    > So anybody knows the solutions of this problem, please and please
    > reply imediately, its urgent.
    >
    > Rahul


    For the formatting option that you have your output will be like:
    01Code 01Desc2000
    and not
    01Code 01Desc 2000

    Also, some of the strings may not be getting formatted properly if
    length of any string in your dataset exceeds the width that you
    specify in the format option.
    Can you show me with your real data?
    GeezerButler, Jun 4, 2007
    #2
    1. Advertising

  3. Rahul

    Rahul Guest

    On Jun 4, 10:38 am, GeezerButler <> wrote:
    > On Jun 4, 10:08 am, Rahul <> wrote:
    >
    >
    >
    >
    >
    > > Friends,

    >
    > > My Problem is related to writing a text file from a database
    > > using .Net. in a particular string format.
    > > I have a dataset with a table, let suppose in this table there are
    > > three fields.
    > > - Code
    > > - Description
    > > - Amount

    >
    > > At the time of writing a text file I use in a for loop -

    >
    > > String.Format("{0,10}{1, 40} {2,-10}", DS.Table(0).Row(i)
    > > ("Code").ToString(), DS.Table(0).Row(i)("Description").ToString(),
    > > DS.Table(0).Row(i)("Amount").ToString())

    >
    > > But the problem is related to the alignment. Data comes like in
    > > following format:

    >
    > > 01Code 01Desc 2000
    > > 02Code 02Desc 3000
    > > 03CodeABC 03Desc 4000
    > > 04xyz 04Desc 5000

    >
    > > I want Data comes in following proper alignment format.

    >
    > > 01Code 01Desc 2000
    > > 02Code 02Desc 3000
    > > 03CodeABC 03Desc 4000
    > > 04xyz 04Desc 5000

    >
    > > So anybody knows the solutions of this problem, please and please
    > > reply imediately, its urgent.

    >
    > > Rahul

    >
    > For the formatting option that you have your output will be like:
    > 01Code 01Desc2000
    > and not
    > 01Code 01Desc 2000
    >
    > Also, some of the strings may not be getting formatted properly if
    > length of any string in your dataset exceeds the width that you
    > specify in the format option.
    > Can you show me with your real data?- Hide quoted text -
    >
    > - Show quoted text -


    thanks for reply
    I have put '-' on the place of space for better understanding.
    This comes for Northwind database, product table
    the real data is :

    alice mutton----------------------------alice mutton

    aniseed syrup---------------------------aniseed syrup

    boston crab meat------------------------boston crab meat

    camembert pierrot-----------------------camembert pierrot

    carnarvon tigers------------------------carnarvon tigers

    chai------------------------------------chai

    chang-----------------------------------chang

    chartreuse verte------------------------chartreuse verte

    chef anton's cajun seasoning------------chef anton's cajun seasoning

    chef anton's gumbo mix------------------chef anton's gumbo mix

    chocolade-------------------------------chocolade

    côte de blaye---------------------------côte de blaye

    escargots de bourgogne------------------escargots de bourgogne

    filo mix--------------------------------filo mix

    flotemysost-----------------------------flotemysost

    geitost---------------------------------geitost

    genen shouyu----------------------------genen shouyu

    gnocchi di nonna alice------------------gnocchi di nonna alice

    gorgonzola telino-----------------------gorgonzola telino

    grandma's boysenberry spread------------grandma's boysenberry spread

    gravad lax------------------------------gravad lax

    guaraná fantástica----------------------guaraná fantástica

    gudbrandsdalsost------------------------gudbrandsdalsost

    gula malacca----------------------------gula malacca

    gumbär gummibärchen---------------------gumbär gummibärchen

    gustaf's knäckebröd---------------------gustaf's knäckebröd

    ikura-----------------------------------ikura

    inlagd sill-----------------------------inlagd sill

    ipoh coffee-----------------------------ipoh coffee

    jack's new england clam chowder---------jack's new england clam
    chowder

    konbu-----------------------------------konbu

    lakkalikööri----------------------------lakkalikööri

    laughing lumberjack lager---------------laughing lumberjack lager

    longlife tofu---------------------------longlife tofu

    louisiana fiery hot pepper sauce--------louisiana fiery hot pepper
    sauce

    louisiana hot spiced okra---------------louisiana hot spiced okra

    manjimup dried apples-------------------manjimup dried apples

    mascarpone fabioli----------------------mascarpone fabioli

    maxilaku--------------------------------maxilaku

    mishi kobe niku-------------------------mishi kobe niku

    mozzarella di giovanni------------------mozzarella di giovanni

    nord-ost matjeshering-------------------nord-ost matjeshering

    northwoods cranberry sauce--------------northwoods cranberry sauce

    nunuca nuß-nougat-creme-----------------nunuca nuß-nougat-creme

    original frankfurter grüne soße---------original frankfurter grüne
    soße

    outback lager---------------------------outback lager

    pâté chinois----------------------------pâté chinois

    pavlova---------------------------------pavlova

    perth pasties---------------------------perth pasties

    queso cabrales--------------------------queso cabrales

    queso manchego la pastora---------------queso manchego la pastora

    raclette courdavault--------------------raclette courdavault

    ravioli angelo--------------------------ravioli angelo

    rhönbräu klosterbier--------------------rhönbräu klosterbier

    röd kaviar------------------------------röd kaviar

    rogede sild-----------------------------rogede sild

    rössle sauerkraut-----------------------rössle sauerkraut

    sasquatch ale---------------------------sasquatch ale

    schoggi schokolade----------------------schoggi schokolade

    scottish longbreads---------------------scottish longbreads

    singaporean hokkien fried mee-----------singaporean hokkien fried mee

    sir rodney's marmalade------------------sir rodney's marmalade

    sir rodney's scones---------------------sir rodney's scones

    sirop d'érable--------------------------sirop d'érable

    spegesild-------------------------------spegesild

    steeleye stout--------------------------steeleye stout

    tarte au sucre--------------------------tarte au sucre

    teatime chocolate biscuits--------------teatime chocolate biscuits

    thüringer rostbratwurst-----------------thüringer rostbratwurst

    tofu------------------------------------tofu

    tourtière-------------------------------tourtière

    tunnbröd--------------------------------tunnbröd

    uncle bob's organic dried pears---------uncle bob's organic dried
    pears

    valkoinen suklaa------------------------valkoinen suklaa

    vegie-spread----------------------------vegie-spread

    wimmers gute semmelknödel---------------wimmers gute semmelknödel

    zaanse koeken---------------------------zaanse koeken


    Rahul
    Rahul, Jun 4, 2007
    #3
  4. You should organize the output into a table with 3 columns. The easiest way
    is to use GridView control databound to your dataset.

    --
    Eliyahu Goldin,
    Software Developer & Consultant
    Microsoft MVP [ASP.NET]
    http://msmvps.com/blogs/egoldin
    http://usableasp.net


    "Rahul" <> wrote in message
    news:...
    > Friends,
    >
    > My Problem is related to writing a text file from a database
    > using .Net. in a particular string format.
    > I have a dataset with a table, let suppose in this table there are
    > three fields.
    > - Code
    > - Description
    > - Amount
    >
    > At the time of writing a text file I use in a for loop -
    >
    > String.Format("{0,10}{1, 40} {2,-10}", DS.Table(0).Row(i)
    > ("Code").ToString(), DS.Table(0).Row(i)("Description").ToString(),
    > DS.Table(0).Row(i)("Amount").ToString())
    >
    >
    > But the problem is related to the alignment. Data comes like in
    > following format:
    >
    > 01Code 01Desc 2000
    > 02Code 02Desc 3000
    > 03CodeABC 03Desc 4000
    > 04xyz 04Desc 5000
    >
    >
    > I want Data comes in following proper alignment format.
    >
    > 01Code 01Desc 2000
    > 02Code 02Desc 3000
    > 03CodeABC 03Desc 4000
    > 04xyz 04Desc 5000
    >
    >
    > So anybody knows the solutions of this problem, please and please
    > reply imediately, its urgent.
    >
    >
    >
    > Rahul
    >
    Eliyahu Goldin, Jun 4, 2007
    #4
  5. On Jun 4, 8:08 am, Rahul <> wrote:
    > On Jun 4, 10:38 am, GeezerButler <> wrote:
    > 01Code 01Desc 2000
    >
    > > Also, some of the strings may not be getting formatted properly if
    > > length of any string in your dataset exceeds the width that you
    > > specify in the format option.
    > > Can you show me with your real data?- Hide quoted text -

    >
    > thanks for reply
    > I have put '-' on the place of space for better understanding.
    > This comes for Northwind database, product table


    I think it's because of the size of the strings.

    When you have

    String.Format("{0,10}....

    it does mean the length of the Code-field cannot be more than 10
    characters, in other case it would shift the whole line.

    Try to change

    String.Format("{0,10}{1, 40} {2,-10}",
    Left(DS.Table(0).Row(i)("Code").ToString(), 10),
    Left(DS.Table(0).Row(i)("Description").ToString(), 40),
    DS.Table(0).Row(i)("Amount").ToString())

    I think it should help
    Alexey Smirnov, Jun 4, 2007
    #5
  6. On Jun 4, 9:02 am, "Eliyahu Goldin"
    <> wrote:
    > You should organize the output into a table with 3 columns. The easiest way
    > is to use GridView control databound to your dataset.
    >
    > --
    > Eliyahu Goldin,
    > Software Developer & Consultant
    > Microsoft MVP [ASP.NET]http://msmvps.com/blogs/egoldinhttp://usableasp.net
    >


    He is writing a text file.
    Alexey Smirnov, Jun 4, 2007
    #6
  7. Rahul

    GeezerButler Guest

    On Jun 4, 11:08 am, Rahul <> wrote:
    > On Jun 4, 10:38 am, GeezerButler <> wrote:
    >
    >
    >
    >
    >
    > > On Jun 4, 10:08 am, Rahul <> wrote:

    >
    > > > Friends,

    >
    > > > My Problem is related to writing a text file from a database
    > > > using .Net. in a particular string format.
    > > > I have a dataset with a table, let suppose in this table there are
    > > > three fields.
    > > > - Code
    > > > - Description
    > > > - Amount

    >
    > > > At the time of writing a text file I use in a for loop -

    >
    > > > String.Format("{0,10}{1, 40} {2,-10}", DS.Table(0).Row(i)
    > > > ("Code").ToString(), DS.Table(0).Row(i)("Description").ToString(),
    > > > DS.Table(0).Row(i)("Amount").ToString())

    >
    > > > But the problem is related to the alignment. Data comes like in
    > > > following format:

    >
    > > > 01Code 01Desc 2000
    > > > 02Code 02Desc 3000
    > > > 03CodeABC 03Desc 4000
    > > > 04xyz 04Desc 5000

    >
    > > > I want Data comes in following proper alignment format.

    >
    > > > 01Code 01Desc 2000
    > > > 02Code 02Desc 3000
    > > > 03CodeABC 03Desc 4000
    > > > 04xyz 04Desc 5000

    >
    > > > So anybody knows the solutions of this problem, please and please
    > > > reply imediately, its urgent.

    >
    > > > Rahul

    >
    > > For the formatting option that you have your output will be like:
    > > 01Code 01Desc2000
    > > and not
    > > 01Code 01Desc 2000

    >
    > > Also, some of the strings may not be getting formatted properly if
    > > length of any string in your dataset exceeds the width that you
    > > specify in the format option.
    > > Can you show me with your real data?- Hide quoted text -

    >
    > > - Show quoted text -

    >
    > thanks for reply
    > I have put '-' on the place of space for better understanding.
    > This comes for Northwind database, product table
    > the real data is :
    >
    > alice mutton----------------------------alice mutton
    >
    > aniseed syrup---------------------------aniseed syrup
    >
    > boston crab meat------------------------boston crab meat
    >
    > camembert pierrot-----------------------camembert pierrot
    >
    > carnarvon tigers------------------------carnarvon tigers
    >
    > chai------------------------------------chai
    >
    > chang-----------------------------------chang
    >
    > chartreuse verte------------------------chartreuse verte
    >
    > chef anton's cajun seasoning------------chef anton's cajun seasoning
    >
    > chef anton's gumbo mix------------------chef anton's gumbo mix
    >
    > chocolade-------------------------------chocolade
    >
    > côte de blaye---------------------------côte de blaye
    >
    > escargots de bourgogne------------------escargots de bourgogne
    >
    > filo mix--------------------------------filo mix
    >
    > flotemysost-----------------------------flotemysost
    >
    > geitost---------------------------------geitost
    >
    > genen shouyu----------------------------genen shouyu
    >
    > gnocchi di nonna alice------------------gnocchi di nonna alice
    >
    > gorgonzola telino-----------------------gorgonzola telino
    >
    > grandma's boysenberry spread------------grandma's boysenberry spread
    >
    > gravad lax------------------------------gravad lax
    >
    > guaraná fantástica----------------------guaraná fantástica
    >
    > gudbrandsdalsost------------------------gudbrandsdalsost
    >
    > gula malacca----------------------------gula malacca
    >
    > gumbär gummibärchen---------------------gumbär gummibärchen
    >
    > gustaf's knäckebröd---------------------gustaf's knäckebröd
    >
    > ikura-----------------------------------ikura
    >
    > inlagd sill-----------------------------inlagd sill
    >
    > ipoh coffee-----------------------------ipoh coffee
    >
    > jack's new england clam chowder---------jack's new england clam
    > chowder
    >
    > konbu-----------------------------------konbu
    >
    > lakkalikööri----------------------------lakkalikööri
    >
    > laughing lumberjack lager---------------laughing lumberjack lager
    >
    > longlife tofu---------------------------longlife tofu
    >
    > louisiana fiery hot pepper sauce--------louisiana fiery hot pepper
    > sauce
    >
    > louisiana hot spiced okra---------------louisiana hot spiced okra
    >
    > manjimup dried apples-------------------manjimup dried apples
    >
    > mascarpone fabioli----------------------mascarpone fabioli
    >
    > maxilaku--------------------------------maxilaku
    >
    > mishi kobe niku-------------------------mishi kobe niku
    >
    > mozzarella di giovanni------------------mozzarella di giovanni
    >
    > nord-ost matjeshering-------------------nord-ost matjeshering
    >
    > northwoods cranberry sauce--------------northwoods cranberry sauce
    >
    > nunuca nuß-nougat-creme-----------------nunuca nuß-nougat-creme
    >
    > original frankfurter grüne soße---------original frankfurter grüne
    > soße
    >
    > outback lager---------------------------outback lager
    >
    > pâté chinois----------------------------pâté chinois
    >
    > pavlova---------------------------------pavlova
    >
    > perth pasties---------------------------perth pasties
    >
    > queso cabrales--------------------------queso cabrales
    >
    > queso manchego la pastora---------------queso manchego la pastora
    >
    > raclette courdavault--------------------raclette courdavault
    >
    > ravioli angelo--------------------------ravioli angelo
    >
    > rhönbräu klosterbier--------------------rhönbräu klosterbier
    >
    > röd kaviar------------------------------röd kaviar
    >
    > rogede sild-----------------------------rogede sild
    >
    > rössle sauerkraut-----------------------rössle sauerkraut
    >
    > sasquatch ale---------------------------sasquatch ale
    >
    > schoggi schokolade----------------------schoggi schokolade
    >
    > scottish longbreads---------------------scottish longbreads
    >
    > singaporean hokkien fried mee-----------singaporean hokkien fried mee
    >
    > sir rodney's marmalade------------------sir rodney's marmalade
    >
    > sir rodney's scones---------------------sir rodney's scones
    >
    > sirop d'érable--------------------------sirop d'érable
    >
    > spegesild-------------------------------spegesild
    >
    > steeleye stout--------------------------steeleye stout
    >
    > tarte au sucre--------------------------tarte au sucre
    >
    > teatime chocolate biscuits--------------teatime chocolate biscuits
    >
    > thüringer rostbratwurst-----------------thüringer rostbratwurst
    >
    > tofu------------------------------------tofu
    >
    > tourtière-------------------------------tourtière
    >
    > tunnbröd--------------------------------tunnbröd
    >
    > uncle bob's organic dried pears---------uncle bob's organic dried
    > pears
    >
    > valkoinen suklaa------------------------valkoinen suklaa
    >
    > vegie-spread----------------------------vegie-spread
    >
    > wimmers gute semmelknödel---------------wimmers gute semmelknödel
    >
    > zaanse koeken---------------------------zaanse koeken
    >
    > Rahul- Hide quoted text -
    >
    > - Show quoted text -


    Are you writing this to a text file or a web page?
    If you copy paste all the data you posted in the post above to
    textpad, you'll see that it is correctly formatted.
    But the same data does not look ok on a web page like this one,
    because the fonts are not monospaced ( i think).
    If you are writing to a web page then follow Eliyahu's advice and bind
    it to some table.
    GeezerButler, Jun 4, 2007
    #7
  8. Rahul

    Rahul Guest

    On Jun 4, 12:13 pm, GeezerButler <> wrote:
    > On Jun 4, 11:08 am, Rahul <> wrote:
    >
    >
    >
    >
    >
    > > On Jun 4, 10:38 am, GeezerButler <> wrote:

    >
    > > > On Jun 4, 10:08 am, Rahul <> wrote:

    >
    > > > > Friends,

    >
    > > > > My Problem is related to writing a text file from a database
    > > > > using .Net. in a particular string format.
    > > > > I have a dataset with a table, let suppose in this table there are
    > > > > three fields.
    > > > > - Code
    > > > > - Description
    > > > > - Amount

    >
    > > > > At the time of writing a text file I use in a for loop -

    >
    > > > > String.Format("{0,10}{1, 40} {2,-10}", DS.Table(0).Row(i)
    > > > > ("Code").ToString(), DS.Table(0).Row(i)("Description").ToString(),
    > > > > DS.Table(0).Row(i)("Amount").ToString())

    >
    > > > > But the problem is related to the alignment. Data comes like in
    > > > > following format:

    >
    > > > > 01Code 01Desc 2000
    > > > > 02Code 02Desc 3000
    > > > > 03CodeABC 03Desc 4000
    > > > > 04xyz 04Desc 5000

    >
    > > > > I want Data comes in following proper alignment format.

    >
    > > > > 01Code 01Desc 2000
    > > > > 02Code 02Desc 3000
    > > > > 03CodeABC 03Desc 4000
    > > > > 04xyz 04Desc 5000

    >
    > > > > So anybody knows the solutions of this problem, please and please
    > > > > reply imediately, its urgent.

    >
    > > > > Rahul

    >
    > > > For the formatting option that you have your output will be like:
    > > > 01Code 01Desc2000
    > > > and not
    > > > 01Code 01Desc 2000

    >
    > > > Also, some of the strings may not be getting formatted properly if
    > > > length of any string in your dataset exceeds the width that you
    > > > specify in the format option.
    > > > Can you show me with your real data?- Hide quoted text -

    >
    > > > - Show quoted text -

    >
    > > thanks for reply
    > > I have put '-' on the place of space for better understanding.
    > > This comes for Northwind database, product table
    > > the real data is :

    >
    > > alice mutton----------------------------alice mutton

    >
    > > aniseed syrup---------------------------aniseed syrup

    >
    > > boston crab meat------------------------boston crab meat

    >
    > > camembert pierrot-----------------------camembert pierrot

    >
    > > carnarvon tigers------------------------carnarvon tigers

    >
    > > chai------------------------------------chai

    >
    > > chang-----------------------------------chang

    >
    > > chartreuse verte------------------------chartreuse verte

    >
    > > chef anton's cajun seasoning------------chef anton's cajun seasoning

    >
    > > chef anton's gumbo mix------------------chef anton's gumbo mix

    >
    > > chocolade-------------------------------chocolade

    >
    > > côte de blaye---------------------------côte de blaye

    >
    > > escargots de bourgogne------------------escargots de bourgogne

    >
    > > filo mix--------------------------------filo mix

    >
    > > flotemysost-----------------------------flotemysost

    >
    > > geitost---------------------------------geitost

    >
    > > genen shouyu----------------------------genen shouyu

    >
    > > gnocchi di nonna alice------------------gnocchi di nonna alice

    >
    > > gorgonzola telino-----------------------gorgonzola telino

    >
    > > grandma's boysenberry spread------------grandma's boysenberry spread

    >
    > > gravad lax------------------------------gravad lax

    >
    > > guaraná fantástica----------------------guaraná fantástica

    >
    > > gudbrandsdalsost------------------------gudbrandsdalsost

    >
    > > gula malacca----------------------------gula malacca

    >
    > > gumbär gummibärchen---------------------gumbär gummibärchen

    >
    > > gustaf's knäckebröd---------------------gustaf's knäckebröd

    >
    > > ikura-----------------------------------ikura

    >
    > > inlagd sill-----------------------------inlagd sill

    >
    > > ipoh coffee-----------------------------ipoh coffee

    >
    > > jack's new england clam chowder---------jack's new england clam
    > > chowder

    >
    > > konbu-----------------------------------konbu

    >
    > > lakkalikööri----------------------------lakkalikööri

    >
    > > laughing lumberjack lager---------------laughing lumberjack lager

    >
    > > longlife tofu---------------------------longlife tofu

    >
    > > louisiana fiery hot pepper sauce--------louisiana fiery hot pepper
    > > sauce

    >
    > > louisiana hot spiced okra---------------louisiana hot spiced okra

    >
    > > manjimup dried apples-------------------manjimup dried apples

    >
    > > mascarpone fabioli----------------------mascarpone fabioli

    >
    > > maxilaku--------------------------------maxilaku

    >
    > > mishi kobe niku-------------------------mishi kobe niku

    >
    > > mozzarella di giovanni------------------mozzarella di giovanni

    >
    > > nord-ost matjeshering-------------------nord-ost matjeshering

    >
    > > northwoods cranberry sauce--------------northwoods cranberry sauce

    >
    > > nunuca nuß-nougat-creme-----------------nunuca nuß-nougat-creme

    >
    > > original frankfurter grüne soße---------original frankfurter grüne
    > > soße

    >
    > > outback lager---------------------------outback lager

    >
    > > pâté chinois----------------------------pâté chinois

    >
    > > pavlova---------------------------------pavlova

    >
    > > perth pasties---------------------------perth pasties

    >
    > > queso cabrales--------------------------queso cabrales

    >
    > > queso manchego la pastora---------------queso manchego la pastora

    >
    > > raclette courdavault--------------------raclette courdavault

    >
    > > ravioli angelo--------------------------ravioli angelo

    >
    > > rhönbräu klosterbier--------------------rhönbräu klosterbier

    >
    > > röd kaviar------------------------------röd kaviar

    >
    > > rogede sild-----------------------------rogede sild

    >
    > > rössle sauerkraut-----------------------rössle sauerkraut

    >
    > > sasquatch ale---------------------------sasquatch ale

    >
    > > schoggi schokolade----------------------schoggi schokolade

    >
    > > scottish longbreads---------------------scottish longbreads

    >
    > > singaporean hokkien fried mee-----------singaporean hokkien fried mee

    >
    > > sir rodney's marmalade------------------sir rodney's marmalade

    >
    > > sir rodney's scones---------------------sir rodney's scones

    >
    > > sirop d'érable--------------------------sirop d'érable

    >
    > > spegesild-------------------------------spegesild

    >
    > > steeleye stout--------------------------steeleye stout

    >
    > > tarte au sucre--------------------------tarte au sucre

    >
    > > teatime chocolate biscuits--------------teatime chocolate biscuits

    >
    > > thüringer rostbratwurst-----------------thüringer rostbratwurst

    >
    > > tofu------------------------------------tofu

    >
    > > tourtière-------------------------------tourtière

    >
    > > tunnbröd--------------------------------tunnbröd

    >
    > > uncle bob's organic dried pears---------uncle bob's organic dried
    > > pears

    >
    > > valkoinen suklaa------------------------valkoinen suklaa

    >
    > > vegie-spread----------------------------vegie-spread

    >
    > > wimmers gute semmelknödel---------------wimmers gute semmelknödel

    >
    > > zaanse koeken---------------------------zaanse koeken

    >
    > > Rahul- Hide quoted text -

    >
    > > - Show quoted text -

    >
    > Are you writing this to a text file or a web page?
    > If you copy paste all the data you posted in the post above to
    > textpad, you'll see that it is correctly formatted.
    > But the same data does not look ok on a web page like this one,
    > because the fonts are not monospaced ( i think).
    > If you are writing to a web page then follow Eliyahu's advice and bind
    > it to some table.- Hide quoted text -
    >
    > - Show quoted text -


    Hi ,

    I am writing in a simple text file.
    here i use '-' character on the place of a single space.

    Rahul
    Rahul, Jun 4, 2007
    #8
  9. On Jun 4, 9:27 am, Rahul <> wrote:
    > Hi ,
    >
    > I am writing in a simple text file.
    > here i use '-' character on the place of a single space.
    >
    > Rahul- Hide quoted text -
    >
    > - Show quoted text -


    If you don't really need a text to be right aligned, you can try to
    use a tab

    e.g.

    String.Format("{0}" & vbTab & "{1}" & vbTab & "{2}", ...
    Alexey Smirnov, Jun 4, 2007
    #9
  10. Rahul

    Rahul Guest

    On Jun 4, 12:10 pm, Alexey Smirnov <> wrote:
    > On Jun 4, 8:08 am, Rahul <> wrote:> On Jun 4, 10:38 am, GeezerButler <> wrote:
    >
    > > 01Code 01Desc 2000

    >
    >
    >
    > > > Also, some of the strings may not be getting formatted properly if
    > > > length of any string in your dataset exceeds the width that you
    > > > specify in the format option.
    > > > Can you show me with your real data?- Hide quoted text -

    >
    > > thanks for reply
    > > I have put '-' on the place of space for better understanding.
    > > This comes for Northwind database, product table

    >
    > I think it's because of the size of the strings.
    >
    > When you have
    >
    > String.Format("{0,10}....
    >
    > it does mean the length of the Code-field cannot be more than 10
    > characters, in other case it would shift the whole line.
    >
    > Try to change
    >
    > String.Format("{0,10}{1, 40} {2,-10}",
    > Left(DS.Table(0).Row(i)("Code").ToString(), 10),
    > Left(DS.Table(0).Row(i)("Description").ToString(), 40),
    > DS.Table(0).Row(i)("Amount").ToString())
    >
    > I think it should help


    Hi,

    I have try it, but not working, and output is same

    String.Format("{0,10}{1, 40} {2,-10}",
    Left(DS.Table(0).Row(i)("Code").ToString(), 10),
    Left(DS.Table(0).Row(i)("Description").ToString(), 40),
    DS.Table(0).Row(i)("Amount").ToString())
    Rahul, Jun 4, 2007
    #10
  11. On Jun 4, 9:35 am, Rahul <> wrote:
    > Hi,
    >
    > I have try it, but not working, and output is same
    >
    > String.Format("{0,10}{1, 40} {2,-10}",
    > Left(DS.Table(0).Row(i)("Code").ToString(), 10),
    > Left(DS.Table(0).Row(i)("Description").ToString(), 40),
    > DS.Table(0).Row(i)("Amount").ToString())- Hide quoted text -
    >
    > - Show quoted text -


    Where do you open the file?

    The text output must be viewed (or printed) with a fixed-width font in
    order to see the correct result. If you use Notepad, click Format -
    Font, and select a fixed-width font, for example, Courier.

    The code to check

    <%@ Import Namespace="System.IO" %>
    <script language="vb" runat="server">
    sub Page_Load(sender as Object, e as EventArgs)

    Dim sw As System.IO.StreamWriter = New
    System.IO.StreamWriter(Server.MapPath("test.txt"))
    sw.WriteLine(String.Format("{0,10}{1, 40} {2,-10}", _
    Left("123", 10), _
    Left("123", 40), _
    "123"))
    sw.WriteLine(String.Format("{0,10}{1, 40} {2,-10}", _
    Left("1234567890123456789", 10), _
    Left("123", 40), _
    "123"))
    sw.WriteLine(String.Format("{0,10}{1, 40} {2,-10}", _
    Left("12345", 10), _
    Left("12345", 40), _
    "12345"))
    sw.Close()

    end sub
    </script>
    Alexey Smirnov, Jun 4, 2007
    #11
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Sunil Menon

    Re: Help required for alignment problem

    Sunil Menon, Jun 26, 2003, in forum: ASP .Net
    Replies:
    0
    Views:
    803
    Sunil Menon
    Jun 26, 2003
  2. Vannela

    Alignment problem in the datagrid

    Vannela, Dec 15, 2003, in forum: ASP .Net
    Replies:
    2
    Views:
    382
    Vannela
    Dec 16, 2003
  3. Gary Coutts

    asp:panel alignment problem

    Gary Coutts, Feb 11, 2006, in forum: ASP .Net
    Replies:
    1
    Views:
    10,755
    papaja
    Feb 11, 2006
  4. Mtmartin71
    Replies:
    9
    Views:
    805
    Adrienne Boswell
    Aug 28, 2007
  5. Bryan

    String matching and alignment?

    Bryan, Jun 9, 2004, in forum: Perl Misc
    Replies:
    4
    Views:
    93
    Joe Smith
    Jun 10, 2004
Loading...

Share This Page