The file I am writing is storing settings for my application. I made a change that needs another setting to be added. My first settings were all booleans and were working fine. The new setting I need to write is a path that I have saved as a string. I can open my binary file and it shows the path after all the weird characters. I was wondering if it should show the string in plain text though. Also, I can't seem to get it to read that portion. Do binary files have issues with strings?
Am I just writing the code wrong? Here are the main parts of my code: A better way is to use a User Defined Type with a variable length string like this: I am writing to this file in one form and reading it in another. Should that type be defined as public in a module? It's not conducive to the general learning of others.
Save a few bits and don't bother. I'll just end up rejecting anyways. When you write the string to a file, then it knows how much it has to write because of the string length. So no problems here But when it's reading the string, how does it VB know how much to read? How does it know where is the end of the string in the file? You have to tell VB how much. There are 2 ways: When you display your string in a text box or label, make sure you trim the NULLs, like: This is also called a "buffer" when used like this.
Before you assign Space 50 to the string, it's an empty buffer, so VB cannot read anything into an empty buffer To fix your problem, I would write your code like this: When you write the data: I could probably make things a little cleaner, but I don't want to break something that I already have working. Thanks for all the help. Results 1 to 7 of 7. Last edited by CVMichael; May 4th, at Better understand the signs that your business has outgrown its current database.
All times are GMT The time now is You may have to register before you can post: To start viewing messages, select the forum that you want to visit from the selection below. Results 1 to 7 of 7 Thread:More...