Solved

Writing a value to text file is being wrongly displayed

Posted on 2007-11-27
1
142 Views
Last Modified: 2010-04-23
I have the following block of simple code which writes the row index of the current selected cell. The odd thing is, when I perform the code, sometimes it will set the correct index in the textfile e.g. row 1 is index 0 I believe, yet other times I will perform it on the same row 1 and the index will be set to 640 or another incorrect number.

Do you see anything wrong:
'This is the code which writes to the text file:

        If Main.TabControl1.SelectedIndex = "3" Then My.Computer.FileSystem.WriteAllText("C:\Old Time Radio\MyFavoriteOTR\Texts\CoupleNextDoor.txt", _

Main.CoupleNextDoorDataGridView.CurrentRow.Index, True)
 

'This is the code which reads from the file (this works fine but is added for clarity)
 

fileReader = My.Computer.FileSystem.ReadAllText("C:\Old Time Radio\MyFavoriteOTR\Texts\CoupleNextDoor.txt")

CoupleNextDoorDataGridView.FirstDisplayedScrollingRowIndex = fileReader

Open in new window

0
Comment
Question by:BIGZIPZ1
1 Comment
 
LVL 11

Accepted Solution

by:
AkisC earned 500 total points
ID: 20360533
Try changing the
Main.CoupleNextDoorDataGridView.CurrentRow.Index
-to-
Me.CoupleNextDoorDataGridView.CurrentRow.Index

.CurrentRow.Index is never wrong...
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Introduction When many people think of the WebBrowser (http://msdn.microsoft.com/en-us/library/2te2y1x6%28v=VS.85%29.aspx) control, they immediately think of a control which allows the viewing and navigation of web pages. While this is true, it's a…
After several hours of googling I could not gather any information on this topic. There are several ways of controlling the USB port connected to any storage device. The best example of that is by changing the registry value of "HKEY_LOCAL_MACHINE\S…
Along with being a a promotional video for my three-day Annielytics Dashboard Seminor, this Micro Tutorial is an intro to Google Analytics API data.
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…

910 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

19 Experts available now in Live!

Get 1:1 Help Now