Solved

VB.net System.IO Write a text file for incrementing number

Posted on 2014-04-07
2
549 Views
Last Modified: 2014-04-07
Hi

I need to use a numbering system in my VB.net app that increments by one every time
I perform an action. I want it to start at 1 then move to 2, then 3 and so on.
What VB.net code would I use to write a text file that handles this?

Thanks
0
Comment
Question by:murbro
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 27

Accepted Solution

by:
MacroShadow earned 500 total points
ID: 39983443
Create a counter variable and add 1 every time that action is preformed.

Dim iCounter As Integer = 0
Dim FILE_NAME As String = "C:\Users\Owner\Documents\test.txt"

If System.IO.File.Exists(FILE_NAME) = True Then
    Dim oWriter As New System.IO.StreamWriter( FILE_NAME )
    oWriter.Write(TextBox1.Text)
    oWriter.Close()
    iCounter = iCounter + 1
    MsgBox("Text written to file")
Else
    MsgBox("File Does Not Exist")
End If

Open in new window

0
 

Author Closing Comment

by:murbro
ID: 39983462
Great! Thanks very much for that
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Since .Net 2.0, Visual Basic has made it easy to create a splash screen and set it via the "Splash Screen" drop down in the Project Properties.  A splash screen set in this manner is automatically created, displayed and closed by the framework itsel…
Introduction As chip makers focus on adding processor cores over increasing clock speed, developers need to utilize the features of modern CPUs.  One of the ways we can do this is by implementing parallel algorithms in our software.   One recent…
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…

735 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question