Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

How do i search for a caridge return line feed

Posted on 2004-10-25
9
Medium Priority
?
243 Views
Last Modified: 2009-07-29
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

0
Comment
Question by:CraigLazar
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
9 Comments
 
LVL 23

Expert Comment

by:Ioannis Paraskevopoulos
ID: 12399027
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)




0
 
LVL 4

Author Comment

by:CraigLazar
ID: 12399160
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
0
 
LVL 23

Expert Comment

by:Ioannis Paraskevopoulos
ID: 12399291
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
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
LVL 23

Expert Comment

by:Ioannis Paraskevopoulos
ID: 12399297
Or you may copy paste the results here so i can help you.


0
 
LVL 52

Expert Comment

by:Carl Tawn
ID: 12399356
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.
0
 
LVL 4

Author Comment

by:CraigLazar
ID: 12399396
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 ?

0
 
LVL 23

Accepted Solution

by:
Ioannis Paraskevopoulos earned 400 total points
ID: 12399412
9 is the code for tab.So you may put vbtab instead of vbcr.

But then you must be sure that alwayw a tab is the dilimeter,or else you won't get the right results.
0
 
LVL 16

Expert Comment

by:jimbobmcgee
ID: 12399452
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.
0
 
LVL 4

Author Comment

by:CraigLazar
ID: 12399707
hey thanks so mmuch , worked like a peach
daved my bacon there :)

cheers
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Suggested Courses

597 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question