473,769 Members | 8,267 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Visual Basic - NonDisplay Characters

44 New Member
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 2608
ADezii
8,834 Recognized Expert Expert
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 Recognized Expert Specialist
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 Recognized Expert Expert
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
NJonge01
44 New Member
Works perfectly!

The only change I had to made was due to a misunderstandin g 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
NJonge01
44 New Member
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
NJonge01
44 New Member
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 Recognized Expert Specialist
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
12216
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 written to a single interface, but support many different manufacturers' barcode scanning devices. I do not want to be tied to one manufacturers' software interfaces. - Must support use of the scanner from Visual Basic, and ideally from C/C++ and...
7
10629
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 namespace std; : : vector<string>* getTyphoon()
4
3318
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 really had to deal with it before. I'm programming a front-end for what is a compiled Fortran program. The VB source does the following to call the Fortran: 'Defines the subroutine. Declare Sub Cycle_DW Lib "cycdw.dll" Alias "CYCDW" (ByRef...
2
2275
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 preparing to upgrade to XP we are finding problems if the result contains particular characters - specifically those above 127 in the ASCII standard table.
6
2198
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 Namespace on new projects. Thus far I have been unable to find this information, please inform me. For example in the Visual Basic Namespace there are Control Characters like Tab and Back and so on. Where are the equivalents in the System Namespace?
14
21975
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" Theyellowmanhadteeth" anything besides characters should be stripped out of the inputed field. this is in visual basic
5
1978
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 numeric plz reply me soon.. thanks in advance . i m waiting 4 ur reply
6
4537
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 recognized by an implementation are implementation defined, and will not necessarily be the same across implementations. The key issue as far as developers are concerned is that if they want their code to be perfectly portable, then they must restrict...
27
1476
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 Studio, I get errors. Console.WriteLine(“Enter your name, please:”);
0
9589
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10216
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10049
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9997
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9865
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8873
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5310
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
3965
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3565
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.