Results 1 to 5 of 5

Thread: LInefeed characters

  1. #1

    Thread Starter
    Member
    Join Date
    Jan 2001
    Posts
    56

    LInefeed characters

    Hi,

    I am getting some value in a excel cell into VB textbox. The value contains some numbers such as 0, 1 etc.

    With the value 0 i am also getting some carriage return and line feed characters(vertical bars). Since i have to perform some action based on the Excel cell value i need to sepearate just the numbers (i.e. 0,1 etc).

    Is there a way just to seperate the numbers from those characters. I would really appreciate some help with this.


    Thanks ,
    Hari

  2. #2
    Frenzied Member KayJay's Avatar
    Join Date
    Jul 2001
    Location
    Chennai
    Posts
    1,849
    Use the replace function.
    VB Code:
    1. newString = Replace(strgVariable, vbCrLf, "")

    "Brothers, you asked for it."
    ...Francisco Domingo Carlos Andres Sebastian D'Anconia

  3. #3
    Member otherones's Avatar
    Join Date
    Jun 2002
    Location
    Milk Factory
    Posts
    59
    Not sure if this is what you are looking for, but this will return everything up to the first non number

    VB Code:
    1. for i = 1 to Len(txtBox.value)
    2.    if Not Mid(txtBox.value,i,1)  like "#" Then
    3.         txtBox.value = Left(txtBox.value, i-1)
    4.         Exit For
    5.    End if
    6. next
    CSC

  4. #4

    Thread Starter
    Member
    Join Date
    Jan 2001
    Posts
    56

    Linefeed characters

    Thanks KJ

    it worked

    Hari

  5. #5
    Frenzied Member KayJay's Avatar
    Join Date
    Jul 2001
    Location
    Chennai
    Posts
    1,849
    UR Welcome.

    Also note that when you import/assign text from an external application/process/code, you will have a problem in differentiating, VBCRLF, VBCR, VBLF. All return as (a) pipe(s).

    So use something like this
    VB Code:
    1. Private Sub Command1_Click()
    2. strng = "Me" & vbCrLf & "My" & vbCr & "Myself" & vbLf
    3.     Text1.Text = strng
    4. strng = Replace(strng, vbCrLf, "")
    5. strng = Replace(strng, vbCr, "")
    6. strng = Replace(strng, vbLf, "")
    7.     Text1.Text = strng
    8. End Sub

    "Brothers, you asked for it."
    ...Francisco Domingo Carlos Andres Sebastian D'Anconia

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width