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!
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"
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.
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.
Re: Creating Text file in formload?
Quote:
Originally Posted by
Dragnorian
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.
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.
Re: Creating Text file in formload?
Quote:
Originally Posted by
Dragnorian
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
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
Then subtract one.
I hope that you can handle that part yourself.
Quote:
Originally Posted by
Dragnorian
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?
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.
Re: Creating Text file in formload?
Quote:
Originally Posted by
wes4dbt
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...
Re: Creating Text file in formload?
Quote:
Originally Posted by
_powerade_
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.
Re: Creating Text file in formload?
Quote:
Originally Posted by
_powerade_
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?
Re: Creating Text file in formload?
Quote:
Originally Posted by
Dragnorian
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
Re: Creating Text file in formload?
Quote:
Originally Posted by
techgnome
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.
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
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.
Re: Creating Text file in formload?
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