Ok i have a file number.txt that by deafult contains the number 1. upon an even happening in my program i want to change this to 2 and then to 3 if the event occures again.
If this is a file generated by your application, which it does sound like since you want to read/change/write back, then you should use the application settings instead to store this value.
About what you asked, is this all content there is in this file? What exactly is your problem with doing this series of operations? everything? You can start by learning how to read the file, for example documentation for my.computer.filesystem object http://msdn2.microsoft.com/en-us/library/microsoft.visualbasic.fileio.filesystem.aspx, or see the first posts of this thread for example http://www.vbdotnetforums.com/showthread.php?t=12782
If reading from a file is not the problem maybe you could be more specific at what tasks you don't know how to do?
well, you get the "1" as text from file, so you have to convert it to a integer, this is convenient with TryParse. Because if you add "1" + "1" strings they concenate to "11", but if you add integer 1 + 1 they add as mathematical numbers to 2.
VB.NET:
Dim int As Integer = 0
If Integer.TryParse("1", int) = True Then
int += 1
MsgBox(int.ToString) 'let you see that int was read 1, added 1 = 2
End If
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.