Solved

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

Posted on 2014-04-07
2
553 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:Murray Brown
[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:Murray Brown
ID: 39983462
Great! Thanks very much for that
0

Featured Post

Technology Partners: 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

A while ago, I was working on a Windows Forms application and I needed a special label control with reflection (glass) effect to show some titles in a stylish way. I've always enjoyed working with graphics, but it's never too clever to re-invent …
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…
Come and listen to Percona CEO Peter Zaitsev discuss what’s new in Percona open source software, including Percona Server for MySQL (https://www.percona.com/software/mysql-database/percona-server) and MongoDB (https://www.percona.com/software/mongo-…
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…

691 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