Link to home
Start Free TrialLog in
Avatar of CraigLazar
CraigLazar

asked on

How do i search for a caridge return line feed

Hi
i am copying data from excel say 10 cels of data,
i am then taking the clipboard into a variable,
i need to write a function to take the values and put them
into seperate variables, but the values are seperated by a little square,
which is a caridge return,

thanks

Avatar of Ioannis Paraskevopoulos
Ioannis Paraskevopoulos
Flag of Greece image

There is the split function,which splits a string to a string array using a specific delimeter.To be more specific i will give you an example.

Lets say you have a sentence ,ex. "Hello my dear friend"

If you write this code

dim mystring as string
dim myarray() as string

mystring = "Hello my dear friend"

myarray=split(mystring," ") 'Which means that you separate each word and the dilimeter is a blank " "


After executing this you will have the following array


myarray(0)="Hello"
myarray(1)="my"
myarray(2)="dear"
myarray(3)="friend"

If you need to have carriage return as the dilimeter use it like this

myarray=split(mystring,vbcr)




Avatar of CraigLazar
CraigLazar

ASKER

hi
sorry did not work
1      2      5      4      5      6      7      8      9      10

here is the data i am working with from the clip board - when i paste it into my text box,
i get little pipe symbols, i need to be able to read the values between the pipes, i tried the replace functiion aswell as vbcr,cbcrlf,vblf - none of them picked them up
Then propably it is not one of those characters.What you can do is using the following sub

Private Sub CharSet(str As String)
For i = 1 To Len(str)
Debug.Print Chr(Asc(Mid(str, i, 1))), "-", Asc(Mid(str, i, 1))
Next
End Sub


When you pass the clipboard to a variable

call this sub like this


CharSet yourClipBoardVariable

With this sub you will know what is the ascii code of the dilimeter character.
Then you may delete the sub and its reference and use

myarray=split(mystring,asc(mycharactercode))

where mycharracter code is the code you will have seen on the immidiate window
Or you may copy paste the results here so i can help you.


To split on a carriage return you can use the VB constant vbCr.

i.e.

    myArray = Split(sYourString, vbCr)

Or, if seperated by a Carriage Return plus a Linefeed then use vbCrLf instead of vbCr.

Hope this helps.
hi
thanks for all the help
this is what was in my debug window
(in excell i just had 1 2 3 in 3 cells, i then copied that to the clipboard
1             -              49
              -              9
2             -              50
              -              9
3             -              51

from here could it be the -        9 val ?

ASKER CERTIFIED SOLUTION
Avatar of Ioannis Paraskevopoulos
Ioannis Paraskevopoulos
Flag of Greece image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
I expect that Excel copies cells to the clipboard as tab delimeted.  If so, using the above code:

      myArray = Split(sYourString, vbTab)

should do it for you...


HTH

J.
hey thanks so mmuch , worked like a peach
daved my bacon there :)

cheers