הערה
הגישה לדף זה מחייבת הרשאה. באפשרותך לנסות להיכנס או לשנות מדריכי כתובות.
הגישה לדף זה מחייבת הרשאה. באפשרותך לנסות לשנות מדריכי כתובות.
Question
Saturday, November 1, 2014 4:29 PM | 1 vote
I'm trying to figure out why a value (read from a text file) is not loading into my form.
I created a "form" (not in the VB sense) from which I read data stored in a text file (via a Do/Loop) and then load it into various text boxes, but for some odd reason, the first box keeps coming up blank.
Assuming the data was just not being read, I put a Watch Value on the variable during debugging. It does indeed contain my data, but Watch displays the value in red. (???)
In the Immediate window, if I print the value (? strSample(1,1)), the data is there, but it's not being assigned to the text box:
txtSample01.Text = strSample(1, 1)
Every box after that loads just fine, just not that first one (the only time it comes up red.) So what does it mean when a watched value is red? Can't be wrong data type. Later reads are just fine.
All replies (3)
Saturday, November 1, 2014 6:20 PM ✅Answered | 2 votes
Usually red means that the watched values was changed, i.e. is different from previously viewed value.
Does the text appear in txtSample01 if you assign some text dirrectly:
* txtSample01.Text = "SOME TEXT"*
Check that txtSample01 is not modified accidentally by some other fragments.
Saturday, November 1, 2014 6:38 PM | 1 vote
Thanks for the reply.
Since the value is red only the first time through, it makes sense that it simply means it changed (from null to having content).
If red simply denotes a change, then there's probably a problem with the input.
PS: Looks like I'm running into the dreaded "BOM characters" glitch. The line is being read, and the variable shows the normal text content, but when assigned to the text box, I get nothing (all text after the BOM characters are being ignored.)
Manually removing the BOM characters from the file fixes the problem, so I'll have to go back and recode the output so it doesn't include them. :(
Thx.
Saturday, November 1, 2014 6:48 PM | 1 vote
By the way, instead of removing byte-order marks (BOM) manually, you can also rely on encoding detection features. For example, File.ReadAllLines can detect BOM. You can also specify your desired encoding. So that the letters will not be lost.