[Help]Code Database

Posts 115 of 41 · Page 1 of 3
[Help]Code Database
First let me define a few things.

This is how the textfile looks like:
Code:
Infinite Lung Capacity
04784976 00000000

Radar Always On
04785D9C AAAAAAAA
Basically all i want to do this create a new item in a listbox for each hack.
So it reads the textfile and creates a new item called "Infinite Lung Capacity" and when it is clicked it will display the code in a textbox.
This will continue until end of textfile.
This is what your are looking for?
but how can you tell the vb.net to create a new listbox item for every string(like letters only).
Quote Originally Posted by ppl2pass View Post
but how can you tell the vb.net to create a new listbox item for every string(like letters only).
If you want to check whether the string contains letters only then use the following function:

Public Function IsLetters(ByVal [String] As String) As Boolean
If IsAlphaNumberic([String]) Then 'Only numbers and letters, good
If Not IsNumeric([String]) Then 'no numbers, good
Return True
End If
End If
Return False
End Function
Also put the following functions in the same class:
Public Function IsNumeric(ByVal [String] As String) As Boolean
For i As Integer = 0 To [String].Length - 1
If Not (AscW([String].Substring(i, 1)) >= 48 AndAlso AscW([String].Substring(i, 1)) <= 57) Then 'asc value range of numbers
Return False
End If
Next
Return True
End Function


Public Function IsAlphaNumberic(ByVal [String] As String) As Boolean
For i As Integer = 0 To [String].Length - 1
If Not (IsNumeric([String].Substring(i, 1)) OrElse _
(AscW([String].Substring(i, 1)) >= 65 AndAlso AscW([String].Substring(i, 1)) <= 90) OrElse _
(AscW([String].Substring(i, 1)) >= 97 AndAlso AscW([String].Substring(i, 1)) <= 122)) Then
'checks asc value range of lower case and upper case letters and check if it's a number, if either fail, then it's not
'only numbers and letters
Return False
End If
Next
Return True
End Function
Now on the form1's load event put the following code:

Dim str as string = "Visual Basic"
If Isletters(str) Then
ListBox1.Items.Add (Str)
End If
Just an example to give you an idea. Re-ask if you need more help
Dynamically creating A listbox is as simple as declaring a new instance and placing it on the form

[php]
Dim listBox1 As New ListBox()
listBox1.Size = New System.Drawing.Size(300, 200)
listBox1.Location = New System.Drawing.Point(25, 25)
Me.Controls.Add(listBox1)
[/php]

From there you can also programatically add content, set multiselect, Columns etc.

This works for any control
@MJLover

How can you make it read a txt file with multiple lines of phrases in it and add a listbox item for each one?
Quote Originally Posted by ppl2pass View Post
@MJLover

How can you make it read a txt file with multiple lines of phrases in it and add a listbox item for each one?
I can't understand what you said. Plz explain with example and I will help you
Basically here is text file:
Code:
Infinite Lung Capacity
04784976 00000000

Radar Always On
04785D9C AAAAAAAA
So how would you read this txtfile and only make a new listbox item for each of the hack title onlys.
Basically the program will create a new listbox for "Infinite Lung Capacity" and "Radar Always On"
Quote Originally Posted by ppl2pass View Post
Basically here is text file:
Code:
Infinite Lung Capacity
04784976 00000000

Radar Always On
04785D9C AAAAAAAA
So how would you read this txtfile and only make a new listbox item for each of the hack title onlys.
Basically the program will create a new listbox for "Infinite Lung Capacity" and "Radar Always On"
Easy:

[php] Dim str As String = My.Computer.FileSystem.ReadAllText("D:\ddd.txt")
str = str.Trim

Dim newStr() As String = str.Split(vbCrLf)
Dim temp As Integer = 1

For Each n As String In newStr
n = n.Trim

If Not n = vbNullString Then

If temp = 0 Then
temp = 1
Continue For
Else
ListBox1.Items.Add(n)
temp = 0
End If

End If
Next[/php]
I am tired, so can't explain the code. I'll explain you later if you want !

By this code you will get this thing:


Insert the first line and ignore the second line
Thanks but i used it for more than one line of code and it didnt work.
I used it for this textfile:
Code:
Gravity modifier [hetoan2]:
05750000 3F8F0000
05750004 00000000
05750008 3F720000
C22CD2CC 00000005
3E808175 C0B40004
FC002840 41800010
C0340000 EC010032
4800000C C1D40008
EC0E0032 00000000

Gravity Modifier OFF [hetoan2]:
042CD2CC EC010032
Basically what your code does is just for every 5 lines or so it creates a new listitembox.
Quote Originally Posted by ppl2pass View Post
Thanks but i used it for more than one line of code and it didnt work.
I used it for this textfile:
Code:
Gravity modifier [hetoan2]:
05750000 3F8F0000
05750004 00000000
05750008 3F720000
C22CD2CC 00000005
3E808175 C0B40004
FC002840 41800010
C0340000 EC010032
4800000C C1D40008
EC0E0032 00000000

Gravity Modifier OFF [hetoan2]:
042CD2CC EC010032
Basically what your code does is just for every 5 lines or so it creates a new listitembox.
Still Easy:

Just remember to put the : at the end of the lines you want to add to listbox.
Example: Gravity Modifier OFF ppl2pass:
Put colon sign at the end always, so we can recognize the items to add.

[php] Dim str As String = My.Computer.FileSystem.ReadAllText("D:\ddd.txt")
str = str.Trim
Dim newStr() As String = str.Split(vbCrLf)
For Each n As String In newStr
n = n.Trim
If Not n = vbNullString Then
If n.EndsWith(":") Then
ListBox1.Items.Add(n)
End If
End If
Next[/php]



Have fun
Very Simple, Nice job Mj

Everyone should brush up on string manipulation, I do have an article in the tuts section.

Also , really suggest (for performance) everyone should learn Database Querying , XML Databases Schema's , or similar.

Database would be optimal here (IMO)
@MJLover thanks so much. definitely give credits to u.

How would you store the code under the name. Like when Gravity modifier is selected. It will show this code in a textbox when "Gravity Modifier" is selected.
Code:
05750000 3F8F0000
05750004 00000000
05750008 3F720000
C22CD2CC 00000005
3E808175 C0B40004
FC002840 41800010
C0340000 EC010032
4800000C C1D40008
EC0E0032 00000000
Code:
Gravity modifier [hetoan2]:
05750000 3F8F0000
05750004 00000000
05750008 3F720000
C22CD2CC 00000005
3E808175 C0B40004
FC002840 41800010
C0340000 EC010032
4800000C C1D40008
EC0E0032 00000000

Gravity Modifier OFF [hetoan2]:
042CD2CC EC010032
--- edit

now that i thought of it. is it even possible?
Quote Originally Posted by ppl2pass View Post
@MJLover thanks so much. definitely give credits to u.

How would you store the code under the name. Like when Gravity modifier is selected. It will show this code in a textbox when "Gravity Modifier" is selected.
Code:
05750000 3F8F0000
05750004 00000000
05750008 3F720000
C22CD2CC 00000005
3E808175 C0B40004
FC002840 41800010
C0340000 EC010032
4800000C C1D40008
EC0E0032 00000000
Code:
Gravity modifier [hetoan2]:
05750000 3F8F0000
05750004 00000000
05750008 3F720000
C22CD2CC 00000005
3E808175 C0B40004
FC002840 41800010
C0340000 EC010032
4800000C C1D40008
EC0E0032 00000000

Gravity Modifier OFF [hetoan2]:
042CD2CC EC010032
--- edit

now that i thought of it. is it even possible?
Absolutely possible and absolutely easy

Double click the listbox and add the following code:

[php]Dim str As String = My.Computer.FileSystem.ReadAllText("D:\ddd.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
[/php]



Sorry for late reply, My internet was down for some hours !!
Enjoy buddy
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
Posts 115 of 41 · Page 1 of 3
This thread is closed for replies.

Similar Threads

Tags for this Thread

None

Need help?