On some games and programs they have a key code. Well how can i make my program ask for a keycode? please help
thanks!
Printable View
On some games and programs they have a key code. Well how can i make my program ask for a keycode? please help
thanks!
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
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.
thanks is there also a way i can stop it from being copy?
yea, one sec.
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
thank i will figure it out
how do i make it so u only have to type it in once??
before asking for the code, check a registry location...if it is false then ask for the code. If it is true then skip the process.Code:dim GotCode as boolean
GotCode = GetSetting(App.Title, "Settings", "GotCode", False)
after the code has been entered correctly, write to the registry locationdoing this will cause the code process to be skipped if the code has been entered correctlyCode:SaveSetting(App.Title, "Settings", "GotCode", True)
kevin
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??
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
oh - and I think you'd be better off using a Select Case statement rather than a sh*tload of GoTo'sCode: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
lol im only 11 and now starting vb6 (i know baTch html & javaS)
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 stataementin your code you read GotCode, but never check itCode:if not GotCode then
'put your key code stuff here
endif
kevin
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
I started coding when I was about 12, and back then they hadn't even discovered dirt yet.:D
Kebo - GetSetting returns the value from the registry - according to the code that CodeErr wrote, it's fairly easy to assume that the values he/she's expecting to return are numeric or string....the only time a boolean will be returned is if that value is stored in the registry (and it is likely that it will be returned as string "True" or string "False" rather than 0 or 1, or True/False), OR if there is no value in the registry, the value False will be returned (using CodeErr's original code because thats the default value that he sends). Using the code I send through, the default value returned would be an empty string.
I try my hardest to stay away from implicit conversions (such as string "True" to boolean True ... I believe that its good programming technique to explicitly convert values if they are going to be retrieved in a different data type than the one you require.
In this case, all information in the registry is stored as string variables, so whatever is returned WILL be a string, although they MIGHT be implicitly converted if they 'fit' the datatype you require.
Might I also suggest that you don't call other people's posts "bogus" until you have checked them in their entirity and ascertained that all the information is false...which in this case, it isn't!
The post I was calling bogus was my accidental post that contained only half of what I was saying. I'm not the type of person to blatently call out someones elses stuff as bogus. sorry for the misunderstanding. As far as the registry values go I use what works and what takes the least amount of lines to code.
kevin
ok - my mistake! Sorry for the misunderstanding :)
I agree with using 'what works', but in this case, you cannot be sure of what will be returned from the registry - only if there's nothing in there will you get an explicit false.
You may get an implicit true if the value returned is non-zero and numeric...but why tempt fate (or tempt your program to crash!)