Solved

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

Posted on 2014-04-07
2
546 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
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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

This article explains how to create and use a custom WaterMark textbox class.  The custom WaterMark textbox class allows you to set the WaterMark Background Color and WaterMark text at design time.   IMAGE OF WATERMARKS STEPS Create VB …
Parsing a CSV file is a task that we are confronted with regularly, and although there are a vast number of means to do this, as a newbie, the field can be confusing and the tools can seem complex. A simple solution to parsing a customized CSV fi…
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…

831 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