473,412 Members | 2,050 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,412 software developers and data experts.

Visual Basic - NonDisplay Characters

I would like to take some data that I've cut and paste from an Excel document. the editor of the excel document has in single cells multiple "rows" of data that I would like to put on single rows of a table in Access. The affect of the multiple rows comes from a "CTRL return" I believe when creating the excel document.

When I paste the excel data into a text document, the multiple rows in the excel spreadsheet appear as a single string with a nondisplay character (representing the CRLF) delimiting them.

when I try to process this text file into a table, I wanted to use the "instr" function of VB to find the non-display character but I don't know how to represent it as the "string" to find.

I ultimately need the position of that non display character to insert the characters before it as 1 row of data and then the characters of data after it as the next row.

Any suggestions?

Thanks!
Oct 6 '07 #1
7 2585
ADezii
8,834 Expert 8TB
I would like to take some data that I've cut and paste from an Excel document. the editor of the excel document has in single cells multiple "rows" of data that I would like to put on single rows of a table in Access. The affect of the multiple rows comes from a "CTRL return" I believe when creating the excel document.

When I paste the excel data into a text document, the multiple rows in the excel spreadsheet appear as a single string with a non-display character (representing the CRLF) delimiting them.

when I try to process this text file into a table, I wanted to use the "instr" function of VB to find the non-display character but I don't know how to represent it as the "string" to find.

I ultimately need the position of that non display character to insert the characters before it as 1 row of data and then the characters of data after it as the next row.

Any suggestions?

Thanks!
Here is a little code I wrote prior to going to bed which will find each occurrence of a Carriage Return (vbCr) in a String and place their positions in an Array (aCRs) for later retrieval. The only Assumption is that the String is in a Text Box named [txtTest]. The test string and code is listed below:
Expand|Select|Wrap|Line Numbers
  1. 'Test String in [txtTest]
  2. Philadelphia
  3. is
  4. the
  5. city
  6. of
  7. brotherly
  8. love.
Expand|Select|Wrap|Line Numbers
  1. Dim intCRPosition  As Integer
  2. Dim intCounter As Integer
  3. Dim aCRs() As Integer       'Array to store the Positions of Carriage Returns
  4.  
  5. intCRPosition = 0           'initialize CR Position
  6.  
  7. For intCounter = 1 To Len(Me![txtTest])
  8.   If Mid$(Me![txtTest], intCounter, 1) = vbCr Then
  9.     intCRPosition = intCRPosition + 1
  10.     ReDim Preserve aCRs(1 To intCRPosition)     'must Redimension Array
  11.       aCRs(intCRPosition) = intCounter
  12.   End If
  13. Next
  14.  
  15. For intCounter = LBound(aCRs) To UBound(aCRs)
  16.   Debug.Print "Carriage Return at position: " & aCRs(intCounter)
  17. Next
OUTPUT:
Expand|Select|Wrap|Line Numbers
  1. Carriage Return at position: 13
  2. Carriage Return at position: 17
  3. Carriage Return at position: 22
  4. Carriage Return at position: 28
  5. Carriage Return at position: 32
  6. Carriage Return at position: 43
NOTE: A Line Feed (vbLf) may or may not be after the Carriage Return (vbCr)
Oct 7 '07 #2
nico5038
3,080 Expert 2GB
I guess that not all fields have this multiple lines problem, but some.
In a case like that I would import the textdata fields with carriage returns into a memo field and create a lookup table to hold the separate values.

After the import some code is needed to extract the multiple values from the textfield and that can be done by using the Split() function and to loop through the created array to insert a line in the lookup table for the unique key of the current record and the found array entry.
In the Split() function the vbCR or the vbCRLF can be used as indicated in the coment ofADezii.

Nic;o)
Oct 7 '07 #3
ADezii
8,834 Expert 8TB
I guess that not all fields have this multiple lines problem, but some.
In a case like that I would import the textdata fields with carriage returns into a memo field and create a lookup table to hold the separate values.

After the import some code is needed to extract the multiple values from the textfield and that can be done by using the Split() function and to loop through the created array to insert a line in the lookup table for the unique key of the current record and the found array entry.
In the Split() function the vbCR or the vbCRLF can be used as indicated in the coment ofADezii.

Nic;o)
Hello Nico, good pickup on the use of the Split() Function. I was focused on the exact positions of the Carriage Returns, and did not consider its use.
Oct 7 '07 #4
Works perfectly!

The only change I had to made was due to a misunderstanding I had of the input data.

I did not realize that vbCF and vbLF could be used separately.

With the clue you gave me, I found that Excel actually creates just the 'line feed'.

When I use your code looking for vbLF in the data that I receive from Excel, it works perfectly!

This will be a very, very helpful utility for me.

Thanks!
Oct 7 '07 #5
I used the code that was created & it works great. I'm not familiar with the "Split" function. I'll read up on that approach. Thank you!
Oct 7 '07 #6
Wow... the split function is really handy.

Given that the need was identified, it was received by MSFT, they developed the function, and now it has been distributed with Visual Basic since who knows when... I guess my technical issue isn't exactly "cutting edge"!

LOL.

Thanks again. This forcum has been extremely helpful to me since discovering it. In order to resolve problems I discover, I only need to post a new question 1 in 5-10 times. Usually the problem has already been discussed.
Oct 7 '07 #7
nico5038
3,080 Expert 2GB
Glad we could help.
Very good that you only needed my cryptical description to find out how the Split does work :-)
I prefer to start giving directions as I don't like to spoil the "I found it" experience :-)

Well done and success with your application !

Nic;o)
Oct 7 '07 #8

Sign in to post your reply or Sign up for a free account.

Similar topics

21
by: CHANGE username to westes | last post by:
What are the most popular, and well supported, libraries of drivers for bar code scanners that include a Visual Basic and C/C++ API? My requirements are: - Must allow an application to be...
7
by: Forecast | last post by:
I run the following code in UNIX compiled by g++ 3.3.2 successfully. : // proj2.cc: returns a dynamic vector and prints out at main~~ : // : #include <iostream> : #include <vector> : : using...
4
by: Cyde Weys | last post by:
I'm currently working on converting a simulator program from Visual Basic 6.0 to Visual C++ .NET. I've figured out most of the stuff, but there's still one thing I haven't gotten to and I've never...
2
by: OG | last post by:
I've looked on google for this but can't find an explanation. Hopefully someone here can help. We use DB2 Connect to link a PC application written in VB6 to OS/390 DB2 (V7) tables. In...
6
by: Chris Lane | last post by:
Hi, I have been searching for a possible list that shows what methods or properties in the System Names replace the ones in the Visual Basic Namespace so I can stop using the Visual Basic...
14
by: boyntonboy242000 | last post by:
Im trying to take only alphabetical characters out of what the users input to the text field (txtinput.text).. So if i put in "The yellow man had 32 teeth!" then im trying to get results like"...
5
by: anianu | last post by:
i want to know how to do validation in visual basic.means how to avoid entering numbers in textbox where we need only characters and also opposite means how to avoid characters where we only need...
6
by: borophyll | last post by:
Hi Please let me know if I have this clear. The basic source character set is the list of (96) characters that all implementations must have in their vocabulary. All other characters...
27
by: Mitch | last post by:
I'm brand new, and just started C# for Dummies. I've also put together a list of websites with code snippets and tutorials. If I cut-and-paste the following line from an example into Visual...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.