Textbox changes text - why (1 Viewer)

kirkm

Registered User.
Local time
Today, 19:33
Joined
Oct 30, 2008
Messages
1,257
Took me ages to find this bug !


txtbox.text = Dat


Dat is a string, len 166
Immediatelt txtbox.text is len 167. The extra character is a chr$(13) that it puts right in the middle (of Dat).


They are no longer the same, so a whole heaps of wrong things happen.
How can I ensure the Access text box does NOT change the string?
 

theDBguy

I’m here to help
Staff member
Local time
Today, 00:33
Joined
Oct 29, 2018
Messages
21,471
Hi. This sounds interesting. I know MS likes to see examples when reporting bugs. Are you able to post a sample database demonstrating the problem?
 

Galaxiom

Super Moderator
Staff member
Local time
Today, 17:33
Joined
Jan 20, 2009
Messages
12,852
Dat is a string, len 166
Immediatelt txtbox.text is len 167. The extra character is a chr$(13) that it puts right in the middle (of Dat).

Is the dat value ultimately coming from a unix system?

Unix new line is a single character, Line Feed or Chr(10).
Windows it is composed of two characters Carriage Return, Chr(13) + Line Feed.

Windows may be converting it automatically so it renders in the text box as a new line. Hence the CR added.
 

kirkm

Registered User.
Local time
Today, 19:33
Joined
Oct 30, 2008
Messages
1,257
Maybe Windows adds the CR character by default.

txtbox.text= "123" & vblf & "123"
Debug.print instr(txtbox.text, chr$(13))


So I'm using Replace to correct it as I read it back. There's no other way anyone knows?
 

Galaxiom

Super Moderator
Staff member
Local time
Today, 17:33
Joined
Jan 20, 2009
Messages
12,852
Check if Chr(10) is in the string.
 

The_Doc_Man

Immoderate Moderator
Staff member
Local time
Today, 02:33
Joined
Feb 28, 2001
Messages
27,179
Good point, G. If the line is coming from a non-Access source, it may be that the input routine is "normalizing" the string to conform to Access format. I have not run into that before for Access but I definitely HAVE run into that sort of string "adjustment" on the mainframe I used to run for the U.S. Navy.
 

Users who are viewing this thread

Top Bottom