Results 1 to 17 of 17

Thread: Creating Text file in formload?

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Nov 2016
    Posts
    95

    Creating Text file in formload?

    Okay, I have figured out what I want to do. I am not looking for answers(full code) just a lead in the right direction. I want to use a timer and everysecond I want it to open that file with the number. Then assign a variable that number. Then subtract one. Save that number to the file, and repeat the process til it reaches 0. I am learning VB.NET in a very unusual way, I know. I have never done this before and am just simply looking for help or a push in the right direction. Thanks!
    Last edited by Dragnorian; May 23rd, 2017 at 08:54 PM. Reason: New Post basically

  2. #2
    PowerPoster
    Join Date
    Sep 2005
    Location
    Modesto, Ca.
    Posts
    5,206

    Re: Creating Text file in formload?

    Well there is tons and tons of examples and information on this subject on the internet and this forum. Google/Search "visual Basic creating a text file" or "visual basic reading a text file"

  3. #3

    Thread Starter
    Lively Member
    Join Date
    Nov 2016
    Posts
    95

    Re: Creating Text file in formload?

    I did that right, but all involved a save dialog or an open dialog and I don't need that.

  4. #4
    PowerPoster
    Join Date
    Sep 2005
    Location
    Modesto, Ca.
    Posts
    5,206

    Re: Creating Text file in formload?

    I don't know what you googled but I googled "visual basic open text file" and there was all kinds of examples that didn't use a opendialog.

  5. #5
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    110,344

    Re: Creating Text file in formload?

    Quote Originally Posted by Dragnorian View Post
    I did that right, but all involved a save dialog or an open dialog and I don't need that.
    That doesn't matter anyway. An OpenFielDialog or SaveFileDialog are only used to get the path of the file anyway. They have nothing actually to do with the opening or saving in the vast majority of cases. That means that any of those examples would be relevant because you can simply use the same code for the opening or saving of the file and use your own file path where they use the FileName from the dialogue.

  6. #6

    Thread Starter
    Lively Member
    Join Date
    Nov 2016
    Posts
    95

    Re: Creating Text file in formload?

    I know that the open and save dialogs only purpose is to get the path. The specific use I need them for though(sorry if I didn't mention it) is when the user installs the software, a txt file with a number will be created when they first run the program and I want that text file to be placed in a path somewhere on the persons computer. That is the part that I need help with.

  7. #7
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    110,344

    Re: Creating Text file in formload?

    Quote Originally Posted by Dragnorian View Post
    I want to use a timer and everysecond I want it to open that file with the number.
    That doesn't really make sense. What number? Are you saying that you want to use a number in a file name? If so then use String.Format to build the file name/path.
    Quote Originally Posted by Dragnorian View Post
    Then assign a variable that number.
    Where did the number come from in the first place if not a variable?
    Quote Originally Posted by Dragnorian View Post
    Then subtract one.
    I hope that you can handle that part yourself.
    Quote Originally Posted by Dragnorian View Post
    Save that number to the file
    That's just writing to a file. What do you not understand about the examples that you've found?

  8. #8
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    110,344

    Re: Creating Text file in formload?

    What is the actual intention here? If explain why you're trying to do this then perhaps the what might become clearer.

  9. #9
    Fanatic Member Arve K.'s Avatar
    Join Date
    Sep 2008
    Location
    Kyrksæterøra, Norway
    Posts
    518

    Re: Creating Text file in formload?

    Quote Originally Posted by wes4dbt View Post
    I don't know what you googled but I googled "visual basic open text file" and there was all kinds of examples that didn't use a opendialog.
    Blah-blah google this and google that blaaahhh.....

    What's the point of having this forum when people "are forced" to google and most likely end up in another forum instead of just posting their questions and get help here? And when you took some of your precious time to google for yourself, couldn't you at least have bothered to actually provided him with some of the links that might have put him towards a solution??

    This forum is slowly dying, I'm sure of it...
    Arve K.

    Please mark your thread as resolved and add reputation to those who helped you solve your problem
    Disclaimer: I am not a professional programmer

  10. #10
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    110,344

    Re: Creating Text file in formload?

    Quote Originally Posted by _powerade_ View Post
    Blah-blah google this and google that blaaahhh.....

    What's the point of having this forum when people "are forced" to google and most likely end up in another forum instead of just posting their questions and get help here? And when you took some of your precious time to google for yourself, couldn't you at least have bothered to actually provided him with some of the links that might have put him towards a solution??

    This forum is slowly dying, I'm sure of it...
    Sometimes people are too lazy to do the simplest thing for themselves and need a prod or a kick to do what they should have already done. Sometimes people don't know what keywords to search for, so giving them the keywords is helping them. If you tell them what you searched for then they will find the same thing with a search themselves, so why do they need the results pasted for them? In my opinion, the point of having this forum is to help people with problems that are too hard for them to solve on their own. If the answer can be found with a web search with obvious keywords then the problem doesn't really qualify as too hard. That's just my opinion but others are free to ignore such opinions when they are posted by me or others if they don't agree with them.

    Mind you, in this case it is looking like the question originally asked isn't even the one that needs answering it, so answering it wouldn't have helped anyone anyway.

  11. #11
    PowerPoster
    Join Date
    Sep 2005
    Location
    Modesto, Ca.
    Posts
    5,206

    Re: Creating Text file in formload?

    Quote Originally Posted by _powerade_ View Post
    Blah-blah google this and google that blaaahhh.....

    What's the point of having this forum when people "are forced" to google and most likely end up in another forum instead of just posting their questions and get help here? And when you took some of your precious time to google for yourself, couldn't you at least have bothered to actually provided him with some of the links that might have put him towards a solution??

    This forum is slowly dying, I'm sure of it...
    First, the OP didn't ask for us to solve his problem. the OP asked for "a push in the right direction". So pointing out where there were examples, is a push in the right direction.

    Second, I don't use text files in my programs, never have. But I've seen this type of question asked and answered dozens (if not hundreds) of times. So, I believe the OP could easily find a better example than what I could provide.

    Third, it's going to be people like you that will kill this forum. You sling insults and provide nothing of benefit for the OP. If not providing the OP with an example truly bothered you then why didn't you provide one?

  12. #12
    Smooth Moperator techgnome's Avatar
    Join Date
    May 2002
    Posts
    34,537

    Re: Creating Text file in formload?

    Quote Originally Posted by Dragnorian View Post
    Okay, I have figured out what I want to do. I am not looking for answers(full code) just a lead in the right direction. I want to use a timer and everysecond I want it to open that file with the number. Then assign a variable that number. Then subtract one. Save that number to the file, and repeat the process til it reaches 0. I am learning VB.NET in a very unusual way, I know. I have never done this before and am just simply looking for help or a push in the right direction. Thanks!
    Ignoring all the noise from the other posts... look at ReadAllLines, ReadAllText, and WriteAllLines and WriteAllText ... since you're only reading one value (and presumably one line) the Lines and Text methods should produce the same result.

    -tg
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

  13. #13

    Thread Starter
    Lively Member
    Join Date
    Nov 2016
    Posts
    95

    Resolved Re: Creating Text file in formload?

    Quote Originally Posted by techgnome View Post
    Ignoring all the noise from the other posts... look at ReadAllLines, ReadAllText, and WriteAllLines and WriteAllText ... since you're only reading one value (and presumably one line) the Lines and Text methods should produce the same result.

    -tg
    Yeah I like that. I spent a couple more hours last night looking at more possibly solutions and came across a YouTube video that used the Settings in the application. I am currently working on a solution that will use the current and start date but along with numbers that those numbers will be the days too to hopefully counter the date change so if the user does say, change the date to try and get longer trial. The numbers will be there to put that in check almost. Once I hopefully figure that out, I will make a post on how to do it whether I figure out the number system or not.

  14. #14
    Smooth Moperator techgnome's Avatar
    Join Date
    May 2002
    Posts
    34,537

    Re: Creating Text file in formload?

    If you want to use Settings, then it's really easy...
    In fact, here's a link to something I wrote a number of years ago.
    http://www.vbforums.com/showthread.p...ighlight=trial

    It's simple, basic, probably could use a lot of work to beef it up some... but there it is.

    -tg
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

  15. #15

    Thread Starter
    Lively Member
    Join Date
    Nov 2016
    Posts
    95

    Re: Creating Text file in formload?

    I am actually using the settings and have figured out a way to put it all in check to counter users changing the date on their computers. I am currently making a post about this tutorial.

  16. #16

    Thread Starter
    Lively Member
    Join Date
    Nov 2016
    Posts
    95

    Re: Creating Text file in formload?

    Thank you as well

  17. #17

    Thread Starter
    Lively Member
    Join Date
    Nov 2016
    Posts
    95

    Re: Creating Text file in formload?

    http://www.vbforums.com/showthread.p...57#post5172257

    That is the tutorial I made for everyone in case you wanted to view it

Tags for this Thread

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