View text file in textbox ,same format as label

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • gobblegob
    New Member
    • Dec 2007
    • 133

    View text file in textbox ,same format as label

    Hi guys,

    This is a very hard question to word. Basically i am opening a .txt file
    into a label, but sometimes the .txt files are too long and you need to
    scroll down. So when i open the txt file into a textbox it is not in the same format as a label , the label seem's to seperate lines and you can read it easier.
    any idea's on how to read as the same format as a label

    Sorry if i havnt explained properly.
    GobbleGob.
  • QVeen72
    Recognized Expert Top Contributor
    • Oct 2006
    • 1445

    #2
    Hi,

    For TextBox set property :

    MultiLine = True

    REgards
    Veena

    Comment

    • gobblegob
      New Member
      • Dec 2007
      • 133

      #3
      Originally posted by QVeen72
      Hi,

      For TextBox set property :

      MultiLine = True

      REgards
      Veena
      Hi Veena,
      That doent seperate line like a label does.

      Comment

      • QVeen72
        Recognized Expert Top Contributor
        • Oct 2006
        • 1445

        #4
        Hi,

        What is the Code, you are using to Populate the Contents of File into Label or Textbox..?

        REgards
        Veena

        Comment

        • gobblegob
          New Member
          • Dec 2007
          • 133

          #5
          Code:
          Dim myselect As String
              myselect = List1.Text
              txtCookie.Text = myselect
              
              Dim file_name As String, curr_line As String
          
              On Error GoTo ERROR_HANDLER
              file_name = App.Path & "\Cookies\" & List1.List(List1.ListIndex)
              Open file_name For Input As #1
                While Not EOF(1)
                   Line Input #1, curr_line
                   txtCookie.Text = txtCookie.Text & curr_line & vbCrLf
                   Label1.Caption = curr_line & vbCrLf
                Wend
              Close #1
            Exit Sub
          ERROR_HANDLER:
             MsgBox Err.Description & ": " & file_name
          this is what im using, When you run this you will see the difference in how the text is displayed differently in the label and textbox.
          i want the textbox to look the same as the label does.

          Thanks

          Comment

          • debasisdas
            Recognized Expert Expert
            • Dec 2006
            • 8119

            #6
            Why are you feeding the textbox and the label separately.

            Comment

            • gobblegob
              New Member
              • Dec 2007
              • 133

              #7
              Originally posted by debasisdas
              Why are you feeding the textbox and the label separately.
              i have both a label and textbox only as reference

              Comment

              • QVeen72
                Recognized Expert Top Contributor
                • Oct 2006
                • 1445

                #8
                Hi,

                For TextBox Set
                ScrollBars = Both, and
                With your code, NewLine Characters are added at the End..

                So, change the code to:

                [code=vb]
                txtCookie.Text = txtCookie.Text & vbcrLF & curr_line
                [/code]


                Regards
                Veena

                Comment

                • gobblegob
                  New Member
                  • Dec 2007
                  • 133

                  #9
                  Originally posted by QVeen72
                  Hi,

                  For TextBox Set
                  ScrollBars = Both, and
                  With your code, NewLine Characters are added at the End..

                  So, change the code to:

                  [code=vb]
                  txtCookie.Text = txtCookie.Text & vbcrLF & curr_line
                  [/code]


                  Regards
                  Veena
                  sorry didnt work :(
                  ok guys try opening a cookie from your comp as text into
                  a label and a textbox and you will see the difference,
                  other than that i cant explain i dont know how to explain it.

                  Sorry guys
                  GobbleGob.

                  Comment

                  • QVeen72
                    Recognized Expert Top Contributor
                    • Oct 2006
                    • 1445

                    #10
                    Hi,

                    Its because, with your Label Control, you are just displaying the Last Line Contents.. Do the same with TextBox..

                    Comment

                    • gobblegob
                      New Member
                      • Dec 2007
                      • 133

                      #11
                      Originally posted by QVeen72
                      Hi,

                      Its because, with your Label Control, you are just displaying the Last Line Contents.. Do the same with TextBox..
                      Hi Qveen,

                      Sorry i dont understand what you mean. Because the label is displaying
                      from the first line then cuts out when the label runs out.

                      Thanks
                      GobbleGob.

                      Comment

                      • QVeen72
                        Recognized Expert Top Contributor
                        • Oct 2006
                        • 1445

                        #12
                        Hi,

                        Try this :

                        txtCookie.Text = curr_line & vbCrLf
                        Label1.Caption = curr_line & vbCrLf

                        Regards
                        Veena

                        Comment

                        • gobblegob
                          New Member
                          • Dec 2007
                          • 133

                          #13
                          Originally posted by QVeen72
                          Hi,

                          Try this :

                          txtCookie.Text = curr_line & vbCrLf
                          Label1.Caption = curr_line & vbCrLf

                          Regards
                          Veena
                          nope sorry thats the same.
                          ok this is what the textbox looks like:

                          1537|839475968| 30651892|970757 120|29917780|*| LSID

                          and label looks like this:

                          1537
                          839475968
                          30651892
                          970757120
                          29917780
                          *
                          LSID

                          i want the textbox to look like the label.
                          the line between the numbers on the textbox are alot thicker.

                          can you see what im saying?

                          GobbleGob

                          Comment

                          Working...