Results 1 to 10 of 10

Thread: rich text box saving in wrong place

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Sep 2018
    Posts
    19

    rich text box saving in wrong place

    OK, because of trouble I have had with such things as 'app.path' AND because I want to make some small but significant improvements to my existing (and working - I have used it successfully for 3-4 years) .exe project I have copied everything from its old location, under the VB98 subfolder, to a dedicated folder elsewhere (c:\charter).
    Everything works properly - apart from one small bug!
    Each time an (astronomical) observation is made, it gets written to 3 places:
    1) A database table
    2) A text file
    3) An on-screen rich text box

    All of this works, apart from the fact that there are now two copies of the text file! One is in the dedicated "c:\charter\obs" folder BUT is empty (it shouldnt be!) The other is back in the \obs folder under VB98 and DOES contain the data. The data appears in the rich text box, so it's being written there properly.

    I have set a breakpoint just after the data gets written to the 3 locations above, and mousing over the relevant text, the name of the empty text file is located in the 'proper' place:

    Code:
    frmEntryscreen.rtbObs.LoadFile frmEntryscreen.todaysfile, rtfText
    frmEntryscreen.rtbObs.SelStart = Len(frmEntryscreen.rtbObs.Text)
    frmEntryscreen.rtbObs.SaveFile frmEntryscreen.todaysfile, rtfText
    so frmEntryscreen.todaysfile is indeed "c:\charter\obs\2024-apr-19.txt" in BOTH .loadfile AND .savefile as it should be - so why is the content of 'todaysfile' not in the file in c\charter\obs but is in a file with the same file name but a different address?
    I really cant work this out. I have looked in the .vbp file in the new location and this is what it says (attached), as I thought there might be some issue with relative addresses:
    Attached Files Attached Files

  2. #2
    PowerPoster SamOscarBrown's Avatar
    Join Date
    Aug 2012
    Location
    NC, USA
    Posts
    9,212

    Re: rich text box saving in wrong place

    Would have to see your code.
    Sam I am (as well as Confused at times).

  3. #3
    Fanatic Member
    Join Date
    Feb 2017
    Posts
    868

    Re: rich text box saving in wrong place

    Taking a WILD GUESS, App.Path is still in force. Make sure use the current path + file name NOT just the file name.
    HTH

  4. #4

    Thread Starter
    Junior Member
    Join Date
    Sep 2018
    Posts
    19

    Re: rich text box saving in wrong place

    Cheers. This is what I have done throughout the project, for that very reason. In fact I could have made a global constant setting it to "c:\charter" although in practice I didnt.
    Every instance (I dont mean that in the programming sense!) is c:\charter\[name of subfolder if any].
    In fact I have just checked by running a project-wide search for "app.path" and it appears just once, in debug.print app.path which line was left over from the previous version in the VB98 folder. Even putting that into operation (ctrl-g) shows that app.path now = c:\charter So there seems to be no reference to the VB folder at all, at least not overtly in the sense of accessible text.
    Last edited by starman1500; Apr 20th, 2024 at 02:44 PM.

  5. #5
    PowerPoster SamOscarBrown's Avatar
    Join Date
    Aug 2012
    Location
    NC, USA
    Posts
    9,212

    Re: rich text box saving in wrong place

    Like I said....you want help (from me) post your your project.
    Sam I am (as well as Confused at times).

  6. #6
    Fanatic Member
    Join Date
    Feb 2017
    Posts
    868

    Re: rich text box saving in wrong place

    Only other thing I can offer if you've checked App.Path and it is set where you want, try a search for a hard coded path that you put in the code and forgot about. What that path is, is known only to you, but an easy search would be for a specific drive (e.g. "c:")
    Other than that, as Sam said: "post your project".

  7. #7

    Thread Starter
    Junior Member
    Join Date
    Sep 2018
    Posts
    19

    Re: rich text box saving in wrong place

    OK, recd and understood. I will take up Sam on his kind offer soon, after trying a few things first.
    Yep, app.path comes out as c:\charter (even though I dont intend to overtly use app.path now).
    One thing I did consider is the fact that when I made the number-only text box (thanks again!), that is in the VB98 folder. Would its location be affecting the rest of the code in some way? I could just copy the .ocx file to my new charter folder...

  8. #8
    Fanatic Member
    Join Date
    Feb 2017
    Posts
    868

    Re: rich text box saving in wrong place

    Would its location be affecting the rest of the code in some way?
    It should NOT.

    Another thing you might check is open the VBP file in notepad and see where all your files are referenced. Maybe certain things are being referenced back to your old folder without you knowing about it.

  9. #9

    Thread Starter
    Junior Member
    Join Date
    Sep 2018
    Posts
    19

    Re: rich text box saving in wrong place

    Thanks. I shall try that too. All useful stuff!

  10. #10

    Thread Starter
    Junior Member
    Join Date
    Sep 2018
    Posts
    19

    Re: rich text box saving in wrong place

    Well, this is weird. I'm pretty sure I didnt change anything crucial, but it is now working properly! Having said that, it's the inconsistency that is a bit of an issue.
    I did have a look at the .vbp file and there were a couple of references there to the VB folder. However they are (1) the number-only textbox and (2) the MS DAO thing that the database uses - and yes I know that DAO isn't flavour of the month but I'm more familiar with it, it does what I want, and this is just a personal app so I'm not going to push my luck!
    But I shall quit while I'm ahead, so thanks everyone who made suggestions. Your help is really appreciated.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width