Link to home
Start Free TrialLog in
Avatar of BIGZIPZ1
BIGZIPZ1

asked on

Writing a value to text file is being wrongly displayed

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

ASKER CERTIFIED SOLUTION
Avatar of AkisC
AkisC
Flag of Greece image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial