martialarts Posted August 3, 2003 Posted August 3, 2003 Hi. I am using VB.NET 2002 Standard. My program creates a textfile of multiples formatted lines. The lines appear similar to the following: Magnesium 50 60 38 48 65 HIGH Calcium 60 70 62 68 40 LOW Albumin 10 20 12 18 25 HIGH The program calculates the whitespace to output to the textfile to make the lines seem like a series of justified columns, similar to a table. The file is being written correctly, but when I open the datafile at a later time in the program, it destroys my perfect whitespacing and the columns are jagged and inconsistent. I am rying to place the text into a label, similar to a print preview. Streamreader and fileopen created the same results. Is there a way I can make this work or do I have to change the format of the text file to a delimited format such as: Magnesium,50,60,38,48,65,HIGH and then add the whitespace when I read from the file and output it to the label? Will this delimited format even allow me to add the proper whitespace and have it displayed correctly in the program? Thanks! Quote
JABE Posted August 3, 2003 Posted August 3, 2003 If the file is written correctly as you have said, then the problem should be in the way you're reading the file. Can you post your snippet that reads the file? Btw, I prefer the csv format because it reduces the file size and it's more flexible because you don't have to change your file-writing routine if any of the fields' length changes. Of course, that's just me :) . Quote
martialarts Posted August 3, 2003 Author Posted August 3, 2003 Thanks for responding. Here is the code I am using: Dim lineOfText As String Dim dataFile As StreamReader dataFile = New StreamReader("vpage1.tmp") lineOfText = dataFile.ReadToEnd lblText.Text = lineOfText I have also tried: FileOpen(1, "vpage1.tmp", OpenMode.Input) lblText.Text = LineInput(1) & vbCrLf & LineInput(1) _ & vbCrLf & LineInput(1) FileClose(1) and several other variants including reading each line individually with streamreader.readline and I have even tried outputting it to a msgbox to see if it had something to do with the text box. Thanks for your time! Quote
*Gurus* divil Posted August 4, 2003 *Gurus* Posted August 4, 2003 Hi, I would guess you're seeing this problem because you're showing the text in a font which isn't fixed-pitch, i.e. spaces and letters won't all be the same size. To display data like that you need to use a fixed pitch font such as Courier New. Quote MVP, Visual Developer - .NET Now you see why evil will always triumph - because good is dumb. My free .NET Windows Forms Controls and Articles
martialarts Posted August 4, 2003 Author Posted August 4, 2003 Thanks. You were right! That also explains why I have had problems aligning columns in other software. I found a short list of fixed-point fonts. I have courier new and lucida console. I am getting ready to deploy this program and I am wondering what will happen if someone doesn't have the fixed-point font on his computer. Will the installer install it or is there something else I can do to make sure it gets installed? I am using VB.NET 2002 standard. Thanks for your time! Quote
*Experts* Volte Posted August 4, 2003 *Experts* Posted August 4, 2003 If you use Courier New, you are safe; if I'm not mistaken, *every* computer with Windows comes installed with Courier New, regardless of options chosen during install. I'm fairly sure it's one of the required fonts. Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.