Hey guys

having a bit of trouble with a bit of code.
This is going to be a bit complicated to explain so i hope i can get the idea across.

The idea is that the following bit of code uses an array called "lines" which has been loaded from a text file in a previous subroutine.

I then want the status of each Checkbox to edit a set of lines in the array.
So Checkbox1 will edit lines(v)
Checkbox2 will edit lines(v+1)
Checkbox3 will edit lines (v+2)
etc... etc....

The below code should check if each check box is checked, if so then it should check the corresponding line in the array and if the first character is a slash it will remove it.

If it is unchecked then the code checks the corresponding line in the array and if there is no slash at the start of the line it adds one.

slashnum() is defined in an earlier subroutine and is either 1 or 0 depending if the first character is a slash.


Checkbox Code:
  1. Sub Save_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Savebutton.Click
  2.         Clicked = True
  3.  
  4.         Dim v = start + 1
  5.         Dim chkBoxes() As CheckBox = {CheckBox1, CheckBox2, CheckBox3, CheckBox4,
  6.                                     CheckBox5, CheckBox6, CheckBox7, CheckBox8,
  7.                                     CheckBox9, CheckBox10, CheckBox11, CheckBox12,
  8.                                     CheckBox13, CheckBox14}
  9.  
  10.         Do While v = UBound(Lines) + 1
  11.  
  12.             For Each chk As CheckBox In chkBoxes
  13.  
  14.                 If chk.Checked = True And slashnum(v) = 0 Then
  15.                     Lines(v) = Mid(Lines(v), 2)
  16.                 End If
  17.                 If CheckBox1.Checked = False And slashnum(v) = 1 Then
  18.                     Lines(v) = "/" & Lines(v)
  19.                 End If
  20.                 v = v + 1
  21.             Next
  22.         Loop
  23.  
  24.         If Savefile(Lines) Then
  25.             MsgBox("File Saved")
  26.         Else
  27.             MsgBox("File Could Not Be Saved")
  28.         End If
  29.     End Sub

The code runs through fine with no errors but it doesnt seem to actually change the array at all. I assume its something incorrect in the way I have set it to loop through all the checkboxes?

Hope I explained that well enough.

Any help would be really handy and much appreciated.

Cheers
Dave