Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Text box problem - newlines ignored

Status
Not open for further replies.

zathrus777

Programmer
Mar 31, 2003
30
GB
I am reading data (text, several paragraphs long) over ADO into an array of textboxes. On one machine where there is a newline in the text it shows as a double pipe and wraps at the edge of the text box.

On another it wraps and starts a new line where a newline character is. Operating systems are the same win2k sp4. Same patches etc. Also does not give newlines on my xp machine at home.

e.g.

blah. blah. blah. blah.

this is wrong it should be.

blah.
blah.
blah.
blah.

As mentioned there are newline characters between all relevant places. Also it works fine in a label.


 
Yes multiline is true in all cases. The character is what you get if you crtl+enter in access which is where the data came from.
 
Notepad shows them incorrectly whereas wordpad shows it correctly

NOTEPAD:"By the end of the course you should have achieved:Improved fitness for everyday life.An understanding of the advantages of an overall exercise programme to help prevent a variety of age-related problems.Improved mobility and ability.Quality of m"

WORDPAD:"By the end of the course you should have achieved:

Improved fitness for everyday life.
An understanding of the advantages of an overall exercise programme to help prevent a variety of age-related problems.
Improved mobility and ability.
Quality of m"

ok I am missing something fundamental here methinks.
 
It looks like you're missing the CR or the LF as JohnYingling says.

To find out which, temporarily add a reference to FSO to your project and run this snippet:

Dim c1 as Long
Dim myStr as StringSet objText = objFSO.OpenTextFile("c:\fred1.txt", _
ForReading, False, TristateUseDefault)
myStr = objText.ReadAll()
Call objText.Close

For c1 = 1 To Len(myStr)
Debug.Print Asc(Mid$(myStr, c1, 1))
Next

Check through the immediate window looking for 10 (LF) or 13 (CR). They should come as a pair each time.

If they don't just replace the one that is there with the CRLF combo. If you see 10 only try:

myStr = Replace(myStr, vbLf, vbCrLf)

________________________________________________________________
If you want to get the best response to a question, please check out FAQ222-2244 first

'If we're supposed to work in Hex, why have we only got A fingers?'
 
johnwm,

Sorry FSO reference. The dim is coming up as a syntax error as I can't find the correct reference.

The text box funnily enough works fine at work - evrything as far as I know is the same here.

 
Sorry. The FileSystemObject is included in Microsoft Scripting Runtime. You can set it under Project|references. The dll is called scrrun.dll

________________________________________________________________
If you want to get the best response to a question, please check out FAQ222-2244 first

'If we're supposed to work in Hex, why have we only got A fingers?'
 
Sorry still no joy. Am using VB6 SP5 on win2k sp4 if that makes a difference. My only other references are:

VBA
VB runtime
VB objects and proc
OLE automation
and MS scripting runtime (just added)

 
OOPS! I've just spotted a missing CR in what I posted. This:

Dim c1 as Long
Dim myStr as StringSet objText = objFSO.OpenTextFile("c:\fred1.txt", _
ForReading, False, TristateUseDefault)
myStr = objText.ReadAll()
Call objText.Close

Should be:
Dim c1 as Long
Dim myStr as String
Set objText = objFSO.OpenTextFile("c:\fred1.txt", _
ForReading, False, TristateUseDefault)
myStr = objText.ReadAll()
Call objText.Close

________________________________________________________________
If you want to get the best response to a question, please check out FAQ222-2244 first

'If we're supposed to work in Hex, why have we only got A fingers?'
 
Private Sub Command1_Click()
Dim myStr As String
Set objText = objFSO.OpenTextFile("c:\fred1.txt", _
ForReading, False, TristateUseDefault)
myStr = objText.ReadAll()
Call objText.Close

For c1 = 1 To Len(myStr)
Debug.Print Asc(Mid$(myStr, c1, 1))
Next
End Sub

Gives a variable not defined at objFSO. Anything else?
 
I normally just post a code snippet if necessary, and don't aim to send complete projects. You will of course need to do any necessary declarations:

Dim objFSO As FileSystemObject
Dim objText As TextStream


________________________________________________________________
If you want to get the best response to a question, please check out FAQ222-2244 first

'If we're supposed to work in Hex, why have we only got A fingers?'
 
johnwm

Am afraid I still get errors when running it (error 91 - object with variable not set). Realised as you were sending the last reply that my hunt for objFSO was fruitless and was mid declaring. It would be nice to see what the code does but I guess not this time - cant expect you to do my job :)

On to my original question of why it would look different on two different machines. One thing I realised was that the version here of the database (MySQL) is 4.01 and at home is 3.23 so am mid looking into that. Thanks for your help so far.

 
Ok thats not it - I just installed the prior database version and copied the data across and it all works fine (I was hoping it came up with the same error).
 
Update: it was due to the database being used. The data in a test database had become corrupted and CR/LF's were messed up. On installing again all works fine. Again thanks for the help.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top