|
-
Nov 29th, 2010, 10:50 PM
#1
Thread Starter
New Member
Weird error with my code???
Here is a PIECE of my code, not the whole thing
Code:
Private Sub label4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Label4.Click
Dim serial As String
Dim length As Integer
Dim byteArray() As Byte
Dim badboy = 0
Dim badboy1 = 0
Dim badboy2 = 0
Dim badboy3 = 0
Dim badboy4 = 0
Dim seriall
length = TextBox1.TextLength
If length < 6 Then
MsgBox("Name must have 6 letters! Closing to prevent patching in a debugger :P", MsgBoxStyle.Information)
Me.Close()
ElseIf length = 6 Or length > 6 Then
serial = ""
serial = serial & TextBox1.Text.Chars(3)
serial = serial & TextBox1.Text.Chars(5)
byteArray = System.Text.ASCIIEncoding.ASCII.GetBytes(serial)
For i As Integer = 0 To byteArray.Length - 1
serial = serial + byteArray(i).ToString("x")
Next
serial = serial.ToUpper
Dim xxx = serial
If TextBox2.Text = serial Then
badboy = 0
Else
badboy = 1
If badboy = 1 Then
Else
badboy = 1
MsgBox("Incorrect serial! Make sure all letters are capitalized!")
badboy1 = 1
badboy2 = 1
badboy3 = 1
badboy4 = 1
MsgBox(serial)
End If
End If
End If
If badboy = 0 Then
seriall = ""
seriall = seriall & TextBox1.Text.Chars(4)
seriall = seriall & TextBox1.Text.Chars(0)
seriall = seriall & TextBox1.Text.Chars(1)
byteArray = System.Text.ASCIIEncoding.ASCII.GetBytes(seriall)
For ilaw As Integer = 0 To byteArray.Length - 1
seriall = seriall + byteArray(ilaw).ToString("x")
Next
seriall = seriall.ToUpper
ilaw = 0
If TextBox3.Text = seriall Then
ilaw = ilaw + 1
Else
If badboy = 1 Then
Else
badboy = 1
badboy1 = 1
badboy2 = 1
MsgBox("Incorrect seriall! Make sure all letters are capitalized!")
badboy3 = 1
MsgBox(seriall)
badboy4 = 1
End If
End If
If badboy = 0 Then
End If
End If
End Sub
It is for a shareware program, but when i click on label 4, it freezes. If you want the full thing, i can give it to you, but it will be stripped of most things. Thanks in advance 
PS. the badboy1 - 4 are so debuggers get messed up, and can't serial phish.
-
Nov 30th, 2010, 06:11 AM
#2
Re: Weird error with my code???
Hi... Welcome to the forums...
Add a Breakpoint on the "Next" statement and run it. Then check the value of "byteArray.Length". See if it is larger or not. If it is much larger, then that's the problem for frozen window. You have to either modify it to perform correctly (if you are not expecting a bigger value there) or try adding Application.DoEvents() line inside the loop.
If my post was helpful to you, then express your gratitude using Rate this Post. 
And if your problem is SOLVED, then please Mark the Thread as RESOLVED (see it in action - video)
My system: AMD FX 6100, Gigabyte Motherboard, 8 GB Crossair Vengance, Cooler Master 450W Thunder PSU, 1.4 TB HDD, 18.5" TFT(Wide), Antec V1 Cabinet
Social Group: VBForums - Developers from India
Skills: PHP, MySQL, jQuery, VB.Net, Photoshop, CodeIgniter, Bootstrap,...
-
Nov 30th, 2010, 08:03 PM
#3
Thread Starter
New Member
Re: Weird error with my code???
Ok did that, but the validation is messed up. It just wont work, here is my code now.
Code:
Private Sub label4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Label4.Click
Dim serial As String
Dim length As Integer
Dim byteArray() As Byte
Dim badboy = 0
Dim badboy1 = 0
Dim badboy2 = 0
Dim badboy3 = 0
Dim badboy4 = 0
Dim seriall
Dim letters = 6
length = TextBox1.TextLength
If length < 6 Then
badboy = 1
MsgBox("Name must have " & letters & " letters!", MsgBoxStyle.Information)
ElseIf length = 6 Or length > 6 Then
If badboy = 1 Then
Else
serial = ""
serial = serial & TextBox1.Text.Chars(3)
serial = serial & TextBox1.Text.Chars(5)
byteArray = System.Text.ASCIIEncoding.ASCII.GetBytes(serial)
serial = ""
For i As Integer = 0 To byteArray.Length - 1
serial = serial + byteArray(i).ToString("x")
Next
serial = serial.ToUpper
If TextBox2.Text = serial Then
badboy = 0
Else
badboy = 1
If badboy = 1 Then
Else
badboy = 1
MsgBox("Incorrect serial! Make sure all letters are capitalized!")
badboy1 = 1
badboy2 = 1
badboy3 = 1
badboy4 = 1
MsgBox(serial)
End If
End If
End If
If badboy = 0 Then
seriall = ""
seriall = seriall & TextBox1.Text.Chars(4)
seriall = seriall & TextBox1.Text.Chars(0)
seriall = seriall & TextBox1.Text.Chars(1)
byteArray = System.Text.ASCIIEncoding.ASCII.GetBytes(seriall)
serial = ""
For ilaw As Integer = 0 To byteArray.Length - 1
seriall = seriall + byteArray(ilaw).ToString("x")
Next
seriall = seriall.ToUpper
ilaw = 0
If TextBox3.Text = seriall Then
ilaw = ilaw + 1
ElseIf badboy = 1 Then
badboy = 1
badboy1 = 1
badboy2 = 1
MsgBox("Incorrect seriall! Make sure all letters are capitalized!")
badboy3 = 1
MsgBox(seriall)
badboy4 = 1
End If
End If
If badboy = 0 Then
End If
End If
-
Dec 1st, 2010, 05:03 AM
#4
Re: Weird error with my code???
I don't know how it works or what you are expecting !
I just trimmed off the extra code and tested the main part:
vb.net Code:
Private Sub Label4_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Label4.Click
Dim serial As String
Dim length As Integer
Dim byteArray() As Byte
length = TextBox1.TextLength
If length < 6 Then
MsgBox("Name must have 6 letters! Closing to prevent patching in a debugger :P", MsgBoxStyle.Information)
Me.Close()
ElseIf length >= 6 Then
serial = TextBox1.Text.Chars(3) & TextBox1.Text.Chars(5)
byteArray = System.Text.ASCIIEncoding.ASCII.GetBytes(serial)
For i As Integer = 0 To byteArray.Length - 1
serial = serial & byteArray(i).ToString("x")
Next
serial = serial.ToUpper
If TextBox2.Text = serial Then
MessageBox.Show("Congratz! You have unlocked the product")
Else
MessageBox.Show("Hmm... Doesn't match ! The code is: " & serial)
End If
End If
End Sub
Are you expecting the same ?
If my post was helpful to you, then express your gratitude using Rate this Post. 
And if your problem is SOLVED, then please Mark the Thread as RESOLVED (see it in action - video)
My system: AMD FX 6100, Gigabyte Motherboard, 8 GB Crossair Vengance, Cooler Master 450W Thunder PSU, 1.4 TB HDD, 18.5" TFT(Wide), Antec V1 Cabinet
Social Group: VBForums - Developers from India
Skills: PHP, MySQL, jQuery, VB.Net, Photoshop, CodeIgniter, Bootstrap,...
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|