Answered by:
How To Make A Register Form?

Question
-
How do you make a register form like for an example if you enter a key in textbox1 and you click register button1 if it is the right key like for an example E8S4D6F (Random key for an example)
button1.enabled =true
(KeyCode E8S4D6F) -needed code there please lol
msgbox("Program Registered")
if the key is wrong it would show
button1.enabled =false
msgbox("Key Invaild")
so if you know any thing that can help me i would be glad lolFriday, April 10, 2009 1:30 AM
Answers
-
If you use a StringCollection setting, need to use this. Note: I named the setting KEYCODE (looks like you left it as Setting).
If My.Settings.KEYCODE.Contains(TextBox1.Text) Then MessageBox.Show("registered") Else MessageBox.Show("key invalid") Button1.Enabled = False End If
I put in A2B8C4D6 and A2B8C4D5 to test it.
Dim mynumber As Integer = 0 Dim total As Integer = 0 Dim OneChar As Char For i = 0 To TextBox1.Text.Length - 1 OneChar = TextBox1.Text.Chars(i) If IsNumeric(OneChar) Then mynumber = Val(TextBox1.Text.Chars(i)) total = total + mynumber End If Next If total = 20 Then MessageBox.Show("Registered") Else MessageBox.Show("Key Invalid") End If
- Edited by jwavila Friday, April 10, 2009 5:56 AM edit
- Proposed as answer by jwavila Friday, April 10, 2009 6:10 AM
- Marked as answer by Xingwei Hu Thursday, April 16, 2009 7:16 AM
Friday, April 10, 2009 5:55 AM -
1. any reason to save the settings in a file? I assume you are talking about a TextFile? Something else? They are part of the program, so no need for a separate file.
2. Do you mean once they have activated it, they don't have to type in the activation key again? If so, create another setting as Type = boolean, Name = Activate. Then where it says MessageBox.Show("Registered"), add another line of code, something like
My.Settings.Activate = True
Then in the form1_Load event, something like (Form2 is the "Activation" form)
If My.Settings.Activate = False then
Form2.ShowDialog
End If
This way if it hasn't been activated, Setting.Activate is False and Form2 will show. Otherwise if it is True, form2 will not show.
Here are a couple of links to read about settings:
http://msdn.microsoft.com/en-us/library/cftf714c.aspx
http://visualbasic.about.com/od/usingvbnet/a/appsettings.htm- Edited by jwavila Friday, April 10, 2009 6:49 AM edit
- Proposed as answer by jwavila Wednesday, April 15, 2009 6:12 AM
- Marked as answer by Xingwei Hu Thursday, April 16, 2009 7:16 AM
Friday, April 10, 2009 6:34 AM
All replies
-
Dim mykey As String = "ABC123" Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click If TextBox1.Text = mykey Then MessageBox.Show("registered") Else MessageBox.Show("key invalid") Button1.Enabled = False End If End Sub
you can also put the key in settings, and check it from there
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click If TextBox1.Text = My.Settings.KEYCODE Then MessageBox.Show("registered") Else MessageBox.Show("key invalid") Button1.Enabled = False End If End Sub
Friday, April 10, 2009 1:43 AM -
Hey thanks but how do i put multiple keys?Friday, April 10, 2009 3:02 AM
-
How many are you talking about?
Depending on how many, in the settings you can enter them as Setting Type = System.Collections.Specialized.StringCollection and then type them all out in the collection. Then see if this collection contains the value entered in the TextBox.
If a lot, it depends on how you are generating your keycode. You can't have a "randomly" generated keycode. How would someone be able to match it? The generation of the keycode has to follow some type of algorithim.Friday, April 10, 2009 5:23 AM -
If i do
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
If TextBox1.Text = My.Settings.Setting Then
MessageBox.Show("Program Registered")
ProSettings.Show()
Close()
Else
MessageBox.Show("Key Invalid")
Button1.Enabled = False
End If
End Sub
i get an error
Error 1 Overload resolution failed because no accessible '=' can be called with these arguments:
'Public Shared Operator =(a As String, b As String) As Boolean': Value of type 'System.Collections.Specialized.StringCollection' cannot be converted to 'String'. C:\Documents and Settings\Terry\My Documents\Visual Studio 2008\Projects\Rogue Killer\Rogue Killer\Rogue Killer\Registerpro.vb 4 12 Rogue KillerFriday, April 10, 2009 5:47 AM -
If you use a StringCollection setting, need to use this. Note: I named the setting KEYCODE (looks like you left it as Setting).
If My.Settings.KEYCODE.Contains(TextBox1.Text) Then MessageBox.Show("registered") Else MessageBox.Show("key invalid") Button1.Enabled = False End If
I put in A2B8C4D6 and A2B8C4D5 to test it.
Dim mynumber As Integer = 0 Dim total As Integer = 0 Dim OneChar As Char For i = 0 To TextBox1.Text.Length - 1 OneChar = TextBox1.Text.Chars(i) If IsNumeric(OneChar) Then mynumber = Val(TextBox1.Text.Chars(i)) total = total + mynumber End If Next If total = 20 Then MessageBox.Show("Registered") Else MessageBox.Show("Key Invalid") End If
- Edited by jwavila Friday, April 10, 2009 5:56 AM edit
- Proposed as answer by jwavila Friday, April 10, 2009 6:10 AM
- Marked as answer by Xingwei Hu Thursday, April 16, 2009 7:16 AM
Friday, April 10, 2009 5:55 AM -
Thanks it worked out great now and again thanks for your helpFriday, April 10, 2009 6:07 AM
-
Wait i got some questions
1.How do you save my settings in a file
2.and if the person gets the key and actavites it how to store into a file and when you open the program again you go to the pro settings it will automaticly go to pro settingsFriday, April 10, 2009 6:18 AM -
1. any reason to save the settings in a file? I assume you are talking about a TextFile? Something else? They are part of the program, so no need for a separate file.
2. Do you mean once they have activated it, they don't have to type in the activation key again? If so, create another setting as Type = boolean, Name = Activate. Then where it says MessageBox.Show("Registered"), add another line of code, something like
My.Settings.Activate = True
Then in the form1_Load event, something like (Form2 is the "Activation" form)
If My.Settings.Activate = False then
Form2.ShowDialog
End If
This way if it hasn't been activated, Setting.Activate is False and Form2 will show. Otherwise if it is True, form2 will not show.
Here are a couple of links to read about settings:
http://msdn.microsoft.com/en-us/library/cftf714c.aspx
http://visualbasic.about.com/od/usingvbnet/a/appsettings.htm- Edited by jwavila Friday, April 10, 2009 6:49 AM edit
- Proposed as answer by jwavila Wednesday, April 15, 2009 6:12 AM
- Marked as answer by Xingwei Hu Thursday, April 16, 2009 7:16 AM
Friday, April 10, 2009 6:34 AM