| View previous topic :: View next topic |
| Author |
Message |
AndrewMan Grandmaster Cheater Supreme
Reputation: 0
Joined: 01 Aug 2007 Posts: 1257
|
Posted: Wed Jun 25, 2008 1:15 pm Post subject: Registry - I give up, please help me. - FIXEDDDDDD!!! |
|
|
Edit fixed: | Code: | Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim r As String
r = My.Computer.Registry.GetValue("HKEY_CURRENT_USER\TestKey", "CheckBox Values", Nothing)
CheckBox1.Checked = r
End Sub |
So i've spent around 5 hours trying to code around with the registry. I basically give up. Please don't tell me "just google it, its on google", because i've been googling for the past 5 hrs, and have seen basically everything on the Registry and .Net. I am going to post all that I have here, and hope that someone has the answer, because I've been doing way to much work, and I've tried everything I can.
I've made just 1 form with a CheckBox and a Button on it.
Every time a user "checks" the CheckBox, it updates the registry:
| Code: | | My.Computer.Registry.SetValue("HKEY_CURRENT_USER\TestKey", "CheckBox Values", CheckBox1.Checked) |
In the button, it tells me the state of the Checkbox using MsgBox:
| Code: | Dim r As String
r = My.Computer.Registry.GetValue("HKEY_CURRENT_USER\TestKey", "CheckBox Values", Nothing)
If r = My.Computer.Registry.GetValue("HKEY_CURRENT_USER\TestKey", "CheckBox Values", True) Then
MsgBox("CheckBox is checked")
ElseIf r = My.Computer.Registry.GetValue("HKEY_CURRENT_USER\TestKey", "CheckBox Values", False) Then
MsgBox("CheckBox is not checked")
End If
End Sub |
Registry pic: Now says "True/False" instead of that data line.
 _________________
Last edited by AndrewMan on Wed Jun 25, 2008 4:58 pm; edited 5 times in total |
|
| Back to top |
|
 |
HomerSexual Grandmaster Cheater Supreme
Reputation: 5
Joined: 03 Feb 2007 Posts: 1657
|
Posted: Wed Jun 25, 2008 1:36 pm Post subject: |
|
|
instead of checking if it's true check if it's 1 or 0 _________________
|
|
| Back to top |
|
 |
AndrewMan Grandmaster Cheater Supreme
Reputation: 0
Joined: 01 Aug 2007 Posts: 1257
|
Posted: Wed Jun 25, 2008 1:37 pm Post subject: |
|
|
| blankrider wrote: | | instead of checking if it's true check if it's 1 or 0 |
Tried, still doesn't work. _________________
|
|
| Back to top |
|
 |
lurc Grandmaster Cheater Supreme
Reputation: 2
Joined: 13 Nov 2006 Posts: 1900
|
Posted: Wed Jun 25, 2008 1:50 pm Post subject: |
|
|
Set the value of the CheckState instead of the CheckBox?
Like instead of "CheckBox1" do "CheckBox1.Checked" or w/e the thing is. _________________
|
|
| Back to top |
|
 |
AndrewMan Grandmaster Cheater Supreme
Reputation: 0
Joined: 01 Aug 2007 Posts: 1257
|
Posted: Wed Jun 25, 2008 1:56 pm Post subject: |
|
|
| lurc wrote: | Set the value of the CheckState instead of the CheckBox?
Like instead of "CheckBox1" do "CheckBox1.Checked" or w/e the thing is. |
Tried that. Still giving me "CheckBox is checked" every time I click the damn button.
This is driving me crazy. Im so pissed off lol. I don't see why this is not working...
Do you know how to make it DWord? _________________
|
|
| Back to top |
|
 |
atom0s Moderator
Reputation: 205
Joined: 25 Jan 2006 Posts: 8587 Location: 127.0.0.1
|
Posted: Wed Jun 25, 2008 4:38 pm Post subject: |
|
|
REG_SZ is a string entry, not a simple yes/no thing in most cases. Such as yours, your entire string inside that entry would need to be compared, not just the first part. Instead of making it a long ass entry like that, just make the name something more forward to that checkbox and use a REG_DWORD entry for the value.
You should really name your controls based on what they are for for this reason.
CheckBox1 for example is misleading and unhelpful to you later down the road if you pick the project back up. You might not remember what the checkbox was for and deal with having to completely relearn your own project. Instead you can do things like:
chkHealthHack
chkAutoattack
And so on (just examples) to better keep track of things. Then you could even in the registry name the entries the control names to make it easier to understand and such. _________________
- Retired. |
|
| Back to top |
|
 |
AndrewMan Grandmaster Cheater Supreme
Reputation: 0
Joined: 01 Aug 2007 Posts: 1257
|
Posted: Wed Jun 25, 2008 4:50 pm Post subject: |
|
|
OMG I FIXED IT!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
Form load:
| Code: | Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim r As String
r = My.Computer.Registry.GetValue("HKEY_CURRENT_USER\TestKey", "CheckBox Values", Nothing)
CheckBox1.Checked = r
End Sub |
_________________
|
|
| Back to top |
|
 |
|