
Originally Posted by
ppl2pass
@MJLover
Thanks for the code.
I used your code for a checkedlistbox.
Ok. This is what i want to do.
If a user checks a checkbox, the code will be written and saved to a textfile. So if "infinite ammo offline" is checked and "infinite health offline" is checked the codes written in the textfile will be:
Code:
042DA3D4 60000000
043B58B8 380000FF
.
How would i do that?
No worries
Just put the following code in the checkedlistbox selected index changed event:
[php]Dim str As String = My.Computer.FileSystem.ReadAllText("D:\ddd.txt")
Dim newFile As String = "D:\newdata.txt"
Try
If chklist.SelectedIndex = chklist.Items.Count - 1 Then
Dim x1 As Integer = str.IndexOf(chklist.SelectedItem, 0) + chklist.SelectedItem.ToString.Length + 1
Dim MJ As String = Mid(str, x1).Trim
TextBox1.Text = MJ
Dim chkstate As CheckState
chkstate = chklist.GetItemCheckState(chklist.SelectedIndex)
If chkstate = CheckState.Checked Then
'You can check whehter the current code is already saved or not in the File. If not then add other wise not to avoid duplicates... It's optional and depends on you

Dim c As String = Nothing
If My.Computer.FileSystem.FileExists(newFile) Then
c = My.Computer.FileSystem.ReadAllText(newFile)
End If
If Not c Is Nothing Then
If Not c.Contains(MJ) Then
My.Computer.FileSystem.WriteAllText(newFile, MJ & vbCrLf, True)
End If
End If
End If
Else
Dim x1 As Integer = str.IndexOf(chklist.SelectedItem, 0) + chklist.SelectedItem.ToString.Length + 1
Dim x2 As Integer = str.IndexOf(chklist.Items(chklist.SelectedIndex + 1), x1) + 1
Dim MJ As String = Mid(str, x1, x2 - x1).Trim
TextBox1.Text = MJ
Dim chkstate As CheckState
chkstate = chklist.GetItemCheckState(chklist.SelectedIndex)
If chkstate = CheckState.Checked Then
'You can check whehter the current code is already saved or not in the File. If not then add other wise not to avoid duplicates... It's optional and depends on you

Dim c As String = Nothing
If My.Computer.FileSystem.FileExists(newFile) Then
c = My.Computer.FileSystem.ReadAllText(newFile)
End If
If Not c Is Nothing Then
If Not c.Contains(MJ) Then
My.Computer.FileSystem.WriteAllText(newFile, MJ & vbCrLf, True)
End If
Else
My.Computer.FileSystem.WriteAllText(newFile, MJ & vbCrLf, True)
End If
End If
End If
Catch ex As Exception
End Try[/php]
Happy hacking or what ever you're doin LOL
