|
-
May 25th, 2010, 08:01 PM
#1
Thread Starter
Lively Member
[Help] Serial Key
ok well i got a serial key and i know how to check it online so here is an example of what i want
Buttons & Box Added
Code:
Textbox1.text = "FE4M-I4D3-TD63-37S2; May 30,2010 " &VbNewline "BF2O-YW18-V3Q2-N3T5; May 36,2010" &VbNewline "5OEN-I7N2-MIR2-NU2U; May 33,2010
Button1.text = "Check"
Textbox2.text = "Enter Serial"
CODE:
Code:
private sub butn clk blah
if textbox2.text = before ";" then
msgbox("yup")
'do stuff / make it only work on your comp
end if
end sub
-
May 26th, 2010, 12:15 AM
#2
Re: [Help] Serial Key
I didn't know that May had 36 days. How are you getting your dates? What is the question you need answered?
-
May 27th, 2010, 02:39 PM
#3
Thread Starter
Lively Member
Re: [Help] Serial Key
 Originally Posted by mbutler755
I didn't know that May had 36 days. How are you getting your dates? What is the question you need answered?
ohh lol thats not the point tho lol bump please and help
-
May 27th, 2010, 02:58 PM
#4
Thread Starter
Lively Member
Re: [Help] Serial Key
oh what im asking is how do i use the before command or between and if it past the date then it will end
-
May 27th, 2010, 03:03 PM
#5
Hyperactive Member
Re: [Help] Serial Key
VB.Net Code:
'>> Textbox1.text = "FE4M-I4D3-TD63-37S2; May 30,2010 "
'correct serial
Dim validSerial As String = "FE4M-I4D3-TD63-37S2"
'substring 'trims' given string till char ';' so it only remains serial inside
' and then you have serial tested against valid serial
If validSerial = Textbox1.Text.Substring(0, Textbox1.Text.LastIndexOf(";")) Then
MsgBox("yup")
'do stuff / make it only work on your comp
End If
I hope I understand what you want. If not, please explain what it is you wanna...
-
May 27th, 2010, 03:23 PM
#6
Thread Starter
Lively Member
Re: [Help] Serial Key
 Originally Posted by Zeljko
VB.Net Code:
'>> Textbox1.text = "FE4M-I4D3-TD63-37S2; May 30,2010 "
'correct serial
Dim validSerial As String = "FE4M-I4D3-TD63-37S2"
'substring 'trims' given string till char ';' so it only remains serial inside
' and then you have serial tested against valid serial
If validSerial = Textbox1.Text.Substring(0, Textbox1.Text.LastIndexOf(";")) Then
MsgBox("yup")
'do stuff / make it only work on your comp
End If
I hope I understand what you want. If not, please explain what it is you wanna...
yess exactly but i do get a error when i do that
Code:
Length cannot be less than zero. Parameter name: length
iit doesnt show up in the error log tho and this will work with mutiple cd keys right
-
May 27th, 2010, 03:57 PM
#7
Re: [Help] Serial Key
your keys shouldn't be hard coded right into the app in plain text like that (for starters) ... and no... as is, it will not work for multiple keys.
as for the error... that happens when you pass a bad length parameter to SubString... meaning that the value is greater than the length available (ie, passing 10, when the string is only 9 characters) ... or if 0 or -1 get passed in.... put a breakpoint on the if statement, check the value of Textbox1.Text ... make sure it has what you think it should have.
Then check Textbox1.Text.LastIndexOf(";") to make sure that is passing back the right value.
-tg
-
May 28th, 2010, 02:33 AM
#8
Hyperactive Member
Re: [Help] Serial Key
 Originally Posted by LoGiCAnti
...this will work with multiple cd keys right
The sample code that I gave you is only a sample to guide you in the right direction. Like techgnome said you should really not save your original serial key like I have did in my sample inside a string.
Let's get back on the sample and show you how you can 'trim-out' multiple string so you can finally test multiple keys:
VB.Net Code:
'remember techgnome: you must ensure that this string has correct legt(it must be > or = to predicted string. Otherrvise this code will fail)
TextBox1.Text = "FE4M-I4D3-TD63-37S2; May 30,2010" & Environment.NewLine & "BF2O-YW18-V3Q2-N3T5; May 36,2010" & Environment.NewLine & "5OEN-I7N2-MIR2-NU2U; May 33,2010"
'create array of strings from above textbox. Do this by dividing it to let say 3 parts (divider is 'Environment.NewLine', result 0: "FE4M-I4D3-TD63-37S2; May 30,2010" , result 1: "BF2O-YW18-V3Q2-N3T5; May 36,2010" ...)
Dim arrStr() As String = Split(TextBox1.Text.ToString, Environment.NewLine)
'cut the right part off
arrStr(0) = arrStr(0).Substring(0, arrStr(0).LastIndexOf(";"))
arrStr(1) = arrStr(1).Substring(0, arrStr(1).LastIndexOf(";"))
arrStr(2) = arrStr(2).Substring(0, arrStr(2).LastIndexOf(";"))
'Like techgnome said you should really not save your original serial key like I have did in my sample inside a string.
'Correct serials writen inside simple text Strings (in real life this is bad to do)
Dim validSerial1 As String = "FE4M-I4D3-TD63-1"
Dim validSerial2 As String = "BF2O-YW18-V3Q2-N3T5" 'only this one will match
Dim validSerial3 As String = "5OEN-I7N2-MIR2-3"
'test 3 serials against all 3 given serials
Dim corectKeys As Integer
If validSerial1 = arrStr(0) Or validSerial1 = arrStr(1) Or validSerial1 = arrStr(2) Then 'first serial is matched to one of serials from textBox
corectKeys += 1 'corectKeys = corectKeys + 1
ElseIf validSerial2 = arrStr(0) Or validSerial2 = arrStr(1) Or validSerial2 = arrStr(2) Then 'second serial is matched to one of serials from textBox
corectKeys += 1
ElseIf validSerial3 = arrStr(0) Or validSerial3 = arrStr(1) Or validSerial3 = arrStr(2) Then 'third serial is matched to one of serials from textBox
corectKeys += 1
Else 'no serial match
corectKeys = 0
End If
If corectKeys > 0 Then 'at least 1 key is corect key...
MsgBox("yup")
Else 'all keys are not working
MsgBox("no no no")
End If
The point of this code is to show you one way of working with strings: dividing it in to parts, test one to another...
The point of this code is NOT to show you how to store sensitiv data (serials) in your app. That is here only to easy the sample...
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
|