Solved

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

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

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

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

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 …
If you're writing a .NET application to connect to an Access .mdb database and use pre-existing queries that require parameters, you've come to the right place! Let's say the pre-existing query(qryCust) in Access takes a Date as a parameter and l…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…

705 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now