[Help]Code Database

Posts 1630 of 41 · Page 2 of 3
Try it out =D

I don't see any problem using a .txt from a website.
Quote Originally Posted by ppl2pass View Post
Would the code work if i had this:

Code:
     
   Dim Web As New System.Net.WebClient
        Dim str As String = Web.DownloadString("http://.txt")

Try
            If ListBox1.SelectedIndex = ListBox1.Items.Count - 1 Then

                Dim x1 As Integer = str.IndexOf(ListBox1.SelectedItem, 0) + ListBox1.SelectedItem.ToString.Length + 1
                Dim MJ As String = Mid(str, x1).Trim
                TextBox1.Text = MJ

            Else
                Dim x1 As Integer = str.IndexOf(ListBox1.SelectedItem, 0) + ListBox1.SelectedItem.ToString.Length + 1
                Dim x2 As Integer = str.IndexOf(ListBox1.Items(ListBox1.SelectedIndex + 1), x1) + 1
                Dim MJ As String = Mid(str, x1, x2 - x1).Trim
                TextBox1.Text = MJ

            End If

        Catch ex As Exception

        End Try
Yes, I think it will work, not tested. But I'll suggest you download the file instead of downloading string !!
This should work...

Code:
Imports System.Net

Public Class Form1

dim str as String

#Region "Settings"
    Const strNotice As String = "http://.txt"

#End Region


Sub LoadNotice()
        Try
            Dim request As HttpWebRequest = WebRequest.Create(strNotice)
            Dim response As HttpWebResponse = request.GetResponse()
            Dim reader As StreamReader = New StreamReader(response.GetResponseStream())
            str = reader.ReadToEnd()
            response.Close()
            reader.Close()
        Catch ex As Exception
            MsgBox(ex.Message)
        End Try
    End Sub


    Private Sub cmdload_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdload.Click

      loadnotice()

Try
            If ListBox1.SelectedIndex = ListBox1.Items.Count - 1 Then

                Dim x1 As Integer = str.IndexOf(ListBox1.SelectedItem, 0) + ListBox1.SelectedItem.ToString.Length + 1
                Dim MJ As String = Mid(str, x1).Trim
                TextBox1.Text = MJ

            Else
                Dim x1 As Integer = str.IndexOf(ListBox1.SelectedItem, 0) + ListBox1.SelectedItem.ToString.Length + 1
                Dim x2 As Integer = str.IndexOf(ListBox1.Items(ListBox1.SelectedIndex + 1), x1) + 1
                Dim MJ As String = Mid(str, x1, x2 - x1).Trim
                TextBox1.Text = MJ

            End If

        Catch ex As Exception

    End Sub

End Class
Still say use a database
Quote Originally Posted by NextGen1 View Post
Still say use a database
Make a tutorial on how to read mssql 2005 data =D

For example...I have a database named "Mpgh" with the tables "User" and "Posts". Now make a comx where to select a User -> the textbox will fill in the current posts of this member. Possible to make this for different people, meaning not just for the admin? So other people would connect to the db? Is this insecure?
Quote Originally Posted by NextGen1 View Post
Still say use a database
Haha, Next I agree with you that it is the optimal way. But for smaller scale, we can use basic string formatting. I don't think for getting some values users will go through the hustle of XML Databases Schema's / SQL / etc...
I agree, Im just .....very ...anti ....txt.

In a-lot of cases the information stored should not be able to be accessed and modified outside of the application, unencrypted text files = easy to manipulate.

But again, I think from a business end alot as well.
@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?
Quote Originally Posted by ppl2pass View Post
@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
thanks sooo much.

too make it easier. i will make a button. so for the check box that are checked, it will write the code into a new text when the "save" button is clicked. how would you do that? sorry if i am asking too much of u.
Quote Originally Posted by ppl2pass View Post
thanks sooo much.

too make it easier. i will make a button. so for the check box that are checked, it will write the code into a new text when the "save" button is clicked. how would you do that? sorry if i am asking too much of u.
Code:
 
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
Quote Originally Posted by ppl2pass View Post
thanks sooo much.

too make it easier. i will make a button. so for the check box that are checked, it will write the code into a new text when the "save" button is clicked. how would you do that? sorry if i am asking too much of u.
Too Easy

Put the following code on button click event:
Just replace the filenames with your's
[php]Dim str As String = My.Computer.FileSystem.ReadAllText("D:\ddd.txt")
Dim newFile As String = "D:\newdataX.txt"
Dim finalstr As String = ""


str = str.Trim
Dim newStr() As String = str.Split(vbCrLf)
Dim curItem As String = ""
For Each n As String In newStr

n = n.Trim
If Not n = vbNullString Then
If n.EndsWith(":") Then

Dim chkstate As CheckState
Dim i As Integer = chklist.Items.IndexOf(n)
chkstate = chklist.GetItemCheckState(i)

If chkstate = CheckState.Unchecked Then
curItem = "X"

Else
curItem = "XX"

End If

Else
If curItem = "X" Then
Continue For
End If
finalstr += n & vbCrLf

End If
End If
Next
If Not finalstr.Trim = vbNullString Then
My.Computer.FileSystem.WriteAllText(newFile, finalstr, False)

End If
[/php]

Pheww


Quote Originally Posted by Blubb1337 View Post
Code:
 
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
Naa, this won't work. This don't even check the checked items !
I did not even take a deeper look at you code, sorry xD

I'm tried, I'ma go to bed nao :P

Why didn't you log on msn
Merged Posts, Watch the double posts
@MJLover I need help from u again.

So right now the code database will list the hacks and the code in the textbox.

This is what im trying to do.
If the user changes the code in the textbox, the code in the textfile will also change so the user can save his/her codes.
How would you do that?
Posts 1630 of 41 · Page 2 of 3
This thread is closed for replies.

Similar Threads

Tags for this Thread

None

Need help?