i have problem in displaying a single line in different line...

my code is

 Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
    Me.TextBox5.Text = Me.ListView1.Items.Count
    Dim oFile As System.IO.File
    Dim oWrite As System.IO.StreamWriter
    oWrite = IO.File.CreateText(" E:\ " & Me.ComboBox1.Text & ".txt")

    oWrite.WriteLine("                              ")
    oWrite.WriteLine("                              ")
    oWrite.WriteLine("                                                          QUOTATION   ")
    oWrite.WriteLine("                              ")
    oWrite.WriteLine("                              ")
    oWrite.WriteLine("                                              {0,10}{1,10}{2,25}", "Date", "Time", "year")
    oWrite.WriteLine("                                              {0,10:dd MMMM}{0,10:hh:mm tt}{1,25:C}", Now(), 2010.33)


    oWrite.WriteLine("                                                                      ")
    oWrite.WriteLine("                               ")
    oWrite.WriteLine("                               ")
    oWrite.WriteLine("                               ")
    oWrite.WriteLine("                              ")
    oWrite.WriteLine("                                                                      ")

    oWrite.WriteLine("                " & Me.ComboBox1.Text & "")
    oWrite.WriteLine("                " & Me.GADD.Text & "")
    oWrite.WriteLine("                " & Me.GFATH.Text & "")
    oWrite.WriteLine("                              ")
    oWrite.WriteLine("                              ")
    oWrite.WriteLine("                              ")
    oWrite.WriteLine("                              ")
    oWrite.WriteLine("                              ")
    oWrite.WriteLine("                              ")
    oWrite.WriteLine("                              ")
    oWrite.WriteLine("                              ")

    If Me.ListView1.Items.Count = 1 Then

        For Each x As ListViewItem In Me.ListView1.Items
            Me.TextBox5.Text = x.Text.Length

            If x.Text.Length < 100 Then
                oWrite.WriteLine("                  " & x.Text & "                                 " & x.SubItems(1).Text & "      " & x.SubItems(5).Text & "    " & x.SubItems(5).Text & ".00            ")
            ElseIf x.Text.Length > 100 Then
                oWrite.WriteLine("                  " & x.Text & "                         " & x.SubItems(1).Text & "      " & x.SubItems(5).Text & "    " & x.SubItems(5).Text & ".00            ")

            End If
        Next
        oWrite.WriteLine("                              ")
        oWrite.WriteLine("                              ")
        oWrite.WriteLine("                              ")
        oWrite.WriteLine("                              ")
        oWrite.WriteLine("                              ")
        oWrite.WriteLine("                              ")
        oWrite.WriteLine("                              ")
        oWrite.WriteLine("                              ")
        oWrite.WriteLine("                              ")
        oWrite.WriteLine("                              ")


    ElseIf Me.ListView1.Items.Count = 2 Then
        For Each x As ListViewItem In Me.ListView1.Items
            Me.TextBox5.Text = x.Text.Length
            If x.Text.Length < 10 Then
                oWrite.WriteLine("                  " & x.Text & "                                 " & x.SubItems(1).Text & "      " & x.SubItems(5).Text & "    " & x.SubItems(5).Text & ".00            ")
            ElseIf x.Text.Length > 10 Then
                oWrite.WriteLine("                  " & x.Text & "                         " & x.SubItems(1).Text & "      " & x.SubItems(5).Text & "    " & x.SubItems(5).Text & ".00            ")
            End If
        Next
        oWrite.WriteLine("                              ")
        oWrite.WriteLine("                              ")
        oWrite.WriteLine("                              ")
        oWrite.WriteLine("                              ")
        oWrite.WriteLine("                              ")
        oWrite.WriteLine("                              ")
        oWrite.WriteLine("                              ")
        oWrite.WriteLine("                              ")
        oWrite.WriteLine("                              ")

    ElseIf Me.ListView1.Items.Count = 3 Then
        For Each x As ListViewItem In Me.ListView1.Items
            Me.TextBox5.Text = x.Text.Length
            If x.Text.Length < 10 Then
                oWrite.WriteLine("                  " & x.Text & "                                 " & x.SubItems(1).Text & "      " & x.SubItems(5).Text & "    " & x.SubItems(5).Text & ".00            ")
            ElseIf x.Text.Length > 10 Then
                oWrite.WriteLine("                  " & x.Text & "                         " & x.SubItems(1).Text & "      " & x.SubItems(5).Text & "    " & x.SubItems(5).Text & ".00            ")
            End If
        Next
        oWrite.WriteLine("                              ")
        oWrite.WriteLine("                              ")
        oWrite.WriteLine("                              ")
        oWrite.WriteLine("                              ")
        oWrite.WriteLine("                              ")
        oWrite.WriteLine("                              ")
        oWrite.WriteLine("                              ")
        oWrite.WriteLine("                              ")


    ElseIf Me.ListView1.Items.Count = 4 Then
        For Each x As ListViewItem In Me.ListView1.Items

            Me.TextBox5.Text = x.Text.Length
            If x.Text.Length < 10 Then
                oWrite.WriteLine("                  " & x.Text & "                                 " & x.SubItems(1).Text & "      " & x.SubItems(5).Text & "    " & x.SubItems(5).Text & ".00            ")
            ElseIf x.Text.Length > 10 Then
                oWrite.WriteLine("                  " & x.Text & "                         " & x.SubItems(1).Text & "      " & x.SubItems(5).Text & "    " & x.SubItems(5).Text & ".00            ")
            End If
        Next
        oWrite.WriteLine("                              ")
        oWrite.WriteLine("                              ")
        oWrite.WriteLine("                              ")
        oWrite.WriteLine("                              ")
        oWrite.WriteLine("                              ")
        oWrite.WriteLine("                              ")
        oWrite.WriteLine("                              ")


    End If
    oWrite.WriteLine("                              ")
    oWrite.WriteLine("                              ")
    oWrite.WriteLine("                              ")
    oWrite.WriteLine("              TERMS AND CONDETION                ")
    oWrite.WriteLine("              The rates shown above are inclsive of taxes.        ")
    oWrite.WriteLine("              Delivery: Within a month from the date of receipt of your valued order  ")
    oWrite.WriteLine("              Price ryling at the date of supply will be applicable                ")
    oWrite.WriteLine("                              ")
    oWrite.WriteLine("              Guarantee will not apply to Tiller damaged during operation                ")
    oWrite.WriteLine("              with attachments other than those supplied by V.S.T. Tillers and                ")
    oWrite.WriteLine("              Raja Industrial Works                ")

    oWrite.Close()
    MsgBox("Record Saved To Notepad")
End Sub

its displaying notepad file as:

                                                      QUOTATION   


                                                Date      Time                     year
                                             06 July  01:56 PM                $2,010.33






            ASDFG
            SADFG
            2451








              1.5 Ton Capacity Trailer two wheeled fitted with the hydrolic break and 600 X 16 tyres /mechanical tipping /Non tipping                               0    0.00            
              1.5 Ton Capacity Trailer two wheeled fitted with the hydrolic break and 600 X 16 tyres /mechanical tipping /Non tipping                         2      13620    13620.00            












          TERMS AND CONDETION                
          The rates shown above are inclsive of taxes.        
          Delivery: Within a month from the date of receipt of your valued order  
          Price ryling at the date of supply will be applicable                

          Guarantee will not apply to Tiller damaged during operation                
          with attachments other than those supplied by V.S.T. Tillers and                
          Raja Industrial Works                

I need This Thing to be like :

                                                      QUOTATION   


                                                Date      Time                     year
                                             06 July  01:56 PM                $2,010.33






            ASDFG
            SADFG
            2451








              1.5 Ton Capacity Trailer two wheeled fitted with
      the hydrolic break and 600 X 16 tyres /mechanical
      tipping /Non tipping                                           0    0.00 

              1.5 Ton Capacity Trailer two wheeled fitted with
      the hydrolic break and 600 X 16 tyres /mechanical
      tipping /Non tipping                                       2      13620    13620.00            












          TERMS AND CONDETION                
          The rates shown above are inclsive of taxes.        
          Delivery: Within a month from the date of receipt of your valued order  
          Price ryling at the date of supply will be applicable                

          Guarantee will not apply to Tiller damaged during operation                
          with attachments other than those supplied by V.S.T. Tillers and                
          Raja Industrial Works

Huh... Reading the whole post makes me dizzy..... x_x...

You can use

WriteLine("testing1\n\n\n\n")

to enter multiple line break though instead of keep calling the WriteLine()... :)

Anyway, the word "condition" is wrongly spell as well... it's "condition" not "condetion"...

hey rahul thanks for replying?
i wrote that code to shaw if there is any error..
in out put you see a file ASDFG.txt file
my client wil use that txt as bill so i want my out put as alligned as below.:


1.5 Ton Capacity Trailer two wheeled fitted with
the hydrolic break and 600 X 16 tyres /mechanical
tipping /Non tipping 0 0.00

1.5 Ton Capacity Trailer two wheeled fitted with
the hydrolic break and 600 X 16 tyres /mechanical
tipping /Non tipping 2 13620 13620.00

Hi
I think I see what your issue is if your text is over a certain value in length you wish to put in a line break but of course not in the middle of a word!
Try something like this:

Sub InsertLineBreaks(ByRef MyInput As String, ByRef MaxLength As Integer, ByRef oWrite As IO.StringWriter)
        Dim MyOutput, sChar As String
        Dim i, x As Integer

        If Len(MyInput) > MaxLength Then
            i = MaxLength
            x = 0
            Do While x < MyInput.Length
                'get inital char at maxlength
                sChar = MyInput.Chars(i)
                Do Until sChar = " "
                    'move back until we hit a space
                    sChar = MyInput.Chars(i)
                    i = i - 1
                Loop
                'output = start of string to the space we've found
                MyOutput = MyInput.Substring(x, i - x)
                oWrite.WriteLine(MyOutput)
                'move start to next string
                x = i + 1
                i = x + MaxLength 'move end so we have max length and repeat proccess
                If i > MyInput.Length Then
                    'i is outside of string length so rest of text will fit.
                    MyOutput = MyInput.Substring(x)
                    oWrite.WriteLine(MyOutput)
                    Exit Do
                End If
            Loop
        Else
            oWrite.WriteLine(MyInput)
        End If
    End Sub
Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.18 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.