Results 1 to 8 of 8

Thread: [Help] Serial Key

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Jan 2010
    Posts
    106

    [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

  2. #2
    Hyperactive Member mbutler755's Avatar
    Join Date
    May 2008
    Location
    Peoria, AZ
    Posts
    417

    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?
    Regards,

    Matt Butler, MBA, BSIT/SE, MCBP
    Owner, Intense IT, LLC
    Find us on Facebook
    Follow us on Twitter
    Link up on LinkedIn
    mb (at) i2t.us

    CODE BANK SUBMISSIONS: Converting Images to Base64 and Back Again

  3. #3

    Thread Starter
    Lively Member
    Join Date
    Jan 2010
    Posts
    106

    Re: [Help] Serial Key

    Quote Originally Posted by mbutler755 View Post
    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

  4. #4

    Thread Starter
    Lively Member
    Join Date
    Jan 2010
    Posts
    106

    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

  5. #5
    Hyperactive Member Zeljko's Avatar
    Join Date
    Oct 2006
    Location
    Internet
    Posts
    441

    Re: [Help] Serial Key

    VB.Net Code:
    1. '>> Textbox1.text = "FE4M-I4D3-TD63-37S2; May 30,2010 "
    2.    'correct serial
    3. Dim validSerial As String = "FE4M-I4D3-TD63-37S2"
    4.    'substring 'trims' given string till char ';' so it only remains serial inside
    5.    ' and then you have serial tested against valid serial
    6. If validSerial = Textbox1.Text.Substring(0, Textbox1.Text.LastIndexOf(";")) Then
    7.    MsgBox("yup")
    8.    'do stuff / make it only work on your comp
    9. End If
    I hope I understand what you want. If not, please explain what it is you wanna...
    1. If this post helped you, please Rate it = That's You, saying Thanks, to Me ...Left side of this post: [Rate this post]
    2. Mark this Thread Resolved if your question has been answered That's You, saying Thanks, to Group ...Menu on top of your original Post: [Thread Tools]>[Mark Thread Resolved]
    3.
    Check my site: www.er-ef.netCheck my snippets: Get installed .NET versionsRegex extractingJoin hierarchically nested Datatables in one flattened Datatable


  6. #6

    Thread Starter
    Lively Member
    Join Date
    Jan 2010
    Posts
    106

    Re: [Help] Serial Key

    Quote Originally Posted by Zeljko View Post
    VB.Net Code:
    1. '>> Textbox1.text = "FE4M-I4D3-TD63-37S2; May 30,2010 "
    2.    'correct serial
    3. Dim validSerial As String = "FE4M-I4D3-TD63-37S2"
    4.    'substring 'trims' given string till char ';' so it only remains serial inside
    5.    ' and then you have serial tested against valid serial
    6. If validSerial = Textbox1.Text.Substring(0, Textbox1.Text.LastIndexOf(";")) Then
    7.    MsgBox("yup")
    8.    'do stuff / make it only work on your comp
    9. 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

  7. #7
    PowerPoster techgnome's Avatar
    Join Date
    May 2002
    Posts
    34,687

    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
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

  8. #8
    Hyperactive Member Zeljko's Avatar
    Join Date
    Oct 2006
    Location
    Internet
    Posts
    441

    Re: [Help] Serial Key

    Quote Originally Posted by LoGiCAnti View Post
    ...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:
    1. 'remember techgnome: you must ensure that this string has correct legt(it must be > or = to predicted string. Otherrvise this code will fail)
    2.         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"
    3.  
    4.         '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" ...)
    5.         Dim arrStr() As String = Split(TextBox1.Text.ToString, Environment.NewLine)
    6.         'cut the right part off
    7.         arrStr(0) = arrStr(0).Substring(0, arrStr(0).LastIndexOf(";"))
    8.         arrStr(1) = arrStr(1).Substring(0, arrStr(1).LastIndexOf(";"))
    9.         arrStr(2) = arrStr(2).Substring(0, arrStr(2).LastIndexOf(";"))
    10.  
    11.         'Like techgnome said you should really not save your original serial key like I have did in my sample inside a string.
    12.         'Correct serials writen inside simple text Strings (in real life this is bad to do)
    13.         Dim validSerial1 As String = "FE4M-I4D3-TD63-1"
    14.         Dim validSerial2 As String = "BF2O-YW18-V3Q2-N3T5"  'only this one will match
    15.         Dim validSerial3 As String = "5OEN-I7N2-MIR2-3"
    16.  
    17.         'test 3 serials against all 3 given serials
    18.         Dim corectKeys As Integer
    19.         If validSerial1 = arrStr(0) Or validSerial1 = arrStr(1) Or validSerial1 = arrStr(2) Then     'first serial is matched to one of serials from textBox
    20.             corectKeys += 1  'corectKeys = corectKeys + 1
    21.         ElseIf validSerial2 = arrStr(0) Or validSerial2 = arrStr(1) Or validSerial2 = arrStr(2) Then 'second serial is matched to one of serials from textBox
    22.             corectKeys += 1
    23.         ElseIf validSerial3 = arrStr(0) Or validSerial3 = arrStr(1) Or validSerial3 = arrStr(2) Then 'third serial is matched to one of serials from textBox
    24.             corectKeys += 1
    25.         Else 'no serial match
    26.             corectKeys = 0
    27.         End If
    28.         If corectKeys > 0 Then 'at least 1 key is corect key...
    29.             MsgBox("yup")
    30.         Else 'all keys are not working
    31.             MsgBox("no no no")
    32.         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...
    1. If this post helped you, please Rate it = That's You, saying Thanks, to Me ...Left side of this post: [Rate this post]
    2. Mark this Thread Resolved if your question has been answered That's You, saying Thanks, to Group ...Menu on top of your original Post: [Thread Tools]>[Mark Thread Resolved]
    3.
    Check my site: www.er-ef.netCheck my snippets: Get installed .NET versionsRegex extractingJoin hierarchically nested Datatables in one flattened Datatable


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width