CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Page 1 of 2 12 LastLast
Results 1 to 15 of 18
  1. #1
    Join Date
    Sep 2003
    Posts
    15

    Key code, How do i add my project a keycode

    On some games and programs they have a key code. Well how can i make my program ask for a keycode? please help


    thanks!

  2. #2
    Join Date
    Sep 2003
    Location
    Washington
    Posts
    143
    Code:
    Private Sub Form_Load()
    
    Form1.Hide
    
    KCODE = InputBox("Keycode: ", "Type Keycode here!", "Keycode here.")
    If KCODE = "'place keycode # here." Then Form1.Show
    If Form1.Visible = False Then MsgBox ("Sorry, Wrong Key!")
    
    Unload Me
    End Sub
    -squaK

  3. #3
    Join Date
    Sep 2003
    Location
    Washington
    Posts
    143
    It doesnt always need to be hidden. You could have a different variable change instead, but i used the visibility change as an easier variable change.
    -squaK

  4. #4
    Join Date
    Sep 2003
    Posts
    15
    thanks is there also a way i can stop it from being copy?

  5. #5
    Join Date
    Sep 2003
    Location
    Washington
    Posts
    143
    yea, one sec.
    -squaK

  6. #6
    Join Date
    Sep 2003
    Location
    Washington
    Posts
    143
    I dont know how you could put this with your code for the Registration key, but i can show you how to detect if ctrl z is pressed.:
    Code:
    Private Sub Form_KeyDown(KeyCode As Integer, ctrl As Integer)
    'which is keycode?
    Debug.Print KeyCode
    'now, when you press a key, you will see in immediate window the number....
    
    
        If ctrl Then
            
            If KeyCode = 90 Then
                MsgBox "<ctrl><z> was pressed"
            End If
        End If
    
    End Sub
    Last edited by squakMix; September 28th, 2003 at 05:33 PM.
    -squaK

  7. #7
    Join Date
    Sep 2003
    Posts
    15
    thank i will figure it out

  8. #8
    Join Date
    Sep 2003
    Posts
    15
    how do i make it so u only have to type it in once??

  9. #9
    Join Date
    Aug 2003
    Location
    Gardnerville,NV
    Posts
    199
    before asking for the code, check a registry location...
    Code:
    dim GotCode as boolean
    GotCode = GetSetting(App.Title, "Settings", "GotCode", False)
    if it is false then ask for the code. If it is true then skip the process.
    after the code has been entered correctly, write to the registry location
    Code:
    SaveSetting(App.Title, "Settings", "GotCode", True)
    doing this will cause the code process to be skipped if the code has been entered correctly
    kevin
    Thank you for your support.
    -Bartyles & James (circa 1980)


    If it helps, rate it
    if it doesn't, well....I tried


    Check out Windows Embedded XP. It's XP compontnetized: add only the components you need to build an OS

    And in knowing that you know nothing, that makes you the smartest of all.
    - Socrates (469 BC - 399 BC)

  10. #10
    Join Date
    Sep 2003
    Posts
    15
    Private Sub Command1_Click()
    Dim GotCode As Boolean
    GotCode = GetSetting(App.Title, "Settings", "GotCode", False)
    If Text1.Text = "546" Then GoTo la1 Else GoTo no:
    la1:
    If Text2.Text = "879" Then GoTo la2 Else GoTo no:
    la2:
    If Text3.Text = "417" Then GoTo la3 Else GoTo no:
    la3:
    If Text4.Text = "639" Then GoTo la4 Else GoTo no:
    la4:
    Form1.Show
    Form3.Hide
    GetSetting(App.Title, "Settings", "GotCode", True)
    GoTo end1:
    no:
    MsgBox "Access Deny.", vbOKOnly, "Dumbas*"
    end1:
    End Sub

    Private Sub Form_Load()
    If GotCode = True Then
    Form1.Show
    Form3.Hide
    End If
    End Sub


    wat wrong??

  11. #11
    Join Date
    Apr 2002
    Location
    Melbourne, Victoria, Australia
    Posts
    1,792
    What's wrong is that you are trying to stuff a string into a boolean variable...and it won't work.

    Create another variable (string) to hold the value returned from GetSetting(), then check whether that variable = ""

    IE

    Code:
    Dim RetValue as string
    RetValue = ""
    RetValue = GetSetting(App.Title, "Settings", "GotCode", "")
    
    If RetValue <> "" then
    ' put your code if the correct value is returned here
    Else
    ' Put your code dealing with the no value returned here
    End If
    oh - and I think you'd be better off using a Select Case statement rather than a sh*tload of GoTo's
    Be nice to Harley riders...

  12. #12
    Join Date
    Sep 2003
    Posts
    15
    lol im only 11 and now starting vb6 (i know baTch html & javaS)

  13. #13
    Join Date
    Aug 2003
    Location
    Gardnerville,NV
    Posts
    199
    CodeErr,

    Once you have read the value of GotCode (which is a Boolean and will be set or not set depending on the registry value of True or False) you have to test it in an if stataement
    Code:
    if not GotCode then
         'put your key code stuff here
    endif
    in your code you read GotCode, but never check it
    kevin
    Thank you for your support.
    -Bartyles & James (circa 1980)


    If it helps, rate it
    if it doesn't, well....I tried


    Check out Windows Embedded XP. It's XP compontnetized: add only the components you need to build an OS

    And in knowing that you know nothing, that makes you the smartest of all.
    - Socrates (469 BC - 399 BC)

  14. #14
    Join Date
    Sep 2003
    Posts
    15
    tHaNks

    i wish i had a forum like this when i was learning batch and stuff they took days to answer and most of the time they couldn't

  15. #15
    Join Date
    Aug 2003
    Location
    Gardnerville,NV
    Posts
    199
    I started coding when I was about 12, and back then they hadn't even discovered dirt yet.
    Thank you for your support.
    -Bartyles & James (circa 1980)


    If it helps, rate it
    if it doesn't, well....I tried


    Check out Windows Embedded XP. It's XP compontnetized: add only the components you need to build an OS

    And in knowing that you know nothing, that makes you the smartest of all.
    - Socrates (469 BC - 399 BC)

Page 1 of 2 12 LastLast

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

Featured