|
-
Feb 1st, 2007, 02:17 PM
#1
Thread Starter
Hyperactive Member
[RESOLVED] Checkbox help
How do i save the value of some checkboxes to a text file
i have 5 checkboxes, when i click save i want to be able to save the status (vbchecked\vbunchecked).
then i want to be able to load them again.
If your question is answered then mark your thread RESOLVED and give credit to whoever answered it.
If you fail, try and try again, its the only way to success.
-
Feb 1st, 2007, 02:19 PM
#2
Hyperactive Member
Re: Checkbox help
is this an option in your program so next time they load it will be the same as they configed? of so then your better saving it to a Reg string
If a post has been usefull then Rate it! 
-
Feb 1st, 2007, 02:20 PM
#3
Thread Starter
Hyperactive Member
Re: Checkbox help
yes but i need to be able to load it on another user account
If your question is answered then mark your thread RESOLVED and give credit to whoever answered it.
If you fail, try and try again, its the only way to success.
-
Feb 1st, 2007, 02:22 PM
#4
Member
Re: Checkbox help
u can save it under HKEY_LOCAL_MACHINE\SOFTWARE\YourApp
it's accessible on all user accounts. but if u need to save setting for indiviusal user accounts use HKEY_CURRENT_USER\SOFTWARE\YourApp
-
Feb 1st, 2007, 02:22 PM
#5
Thread Starter
Hyperactive Member
Re: Checkbox help
im trying to set restrictions with my program i need to beable to save the restrictions for other users
If your question is answered then mark your thread RESOLVED and give credit to whoever answered it.
If you fail, try and try again, its the only way to success.
-
Feb 1st, 2007, 02:23 PM
#6
Thread Starter
Hyperactive Member
Re: Checkbox help
thanks how would i do it for a specific user
If your question is answered then mark your thread RESOLVED and give credit to whoever answered it.
If you fail, try and try again, its the only way to success.
-
Feb 1st, 2007, 02:26 PM
#7
Hyperactive Member
Re: Checkbox help
to save use something like:
VB Code:
SaveSetting App.EXEName, "Programname", "UsernameCheck", Check1.value
do something like that but were i have put "UsernameCheck" you would put there username so if they have setup an account the have a variable with there name in it and use Variable & "Check".
to load you can use:
VB Code:
Check1.value GetSetting(App.EXEName, "Programname", "UsernameCheck", "")
yet again with usernamecheck you would need to use Variable & "Check"
If a post has been usefull then Rate it! 
-
Feb 1st, 2007, 02:27 PM
#8
Re: Checkbox help
VB Code:
Private Sub Form_Load()
Dim tmp() As String
Dim chks() As String
If Len(Dir(App.paht & "\checks.dat")) <> 0 Then
Open App.Path & "\checks.dat" For Input As #1
tmp = Split(Input(LOF(1), 1), vbCrLf)
Close #1
For X = 0 To UBound(tmp)
If tmp(X) <> "" Then
chks = Split(tmp(X), ",")
Me.Controls(chks(0)).Value = chks(1)
End If
Next
End If
End Sub
Private Sub Form_Unload(Cancel As Integer)
Dim ctl As Control
Open App.Path & "\checks.dat" For Output As #1
For Each ctl In Me.Controls
If TypeOf ctl Is CheckBox Then
Print #1, ctl.Name & "," & ctl.Value
End If
Next
Close #1
End Sub
JPnyc rocks!! (Just ask him!)
If u have your answer please go to the thread tools and click "Mark Thread Resolved"
-
Feb 1st, 2007, 02:44 PM
#9
Thread Starter
Hyperactive Member
Re: Checkbox help
thanks for all your help i have got a few options now.
Another question:
as the check boxes are applying restrictions using the registry, Is there away i can edit the keys i am using to apply them to certain users.
at the moment i am using the regkey below
HKEY_CURRENT_USER\SOFTWARE\Microsoft\
this way i have to log on to every user account and set the restrictions.
could i use something like this instead
Username\SOFTWARE\Microsoft\
so if it was me
Chris\SOFTWARE\Microsoft\
If your question is answered then mark your thread RESOLVED and give credit to whoever answered it.
If you fail, try and try again, its the only way to success.
-
Feb 1st, 2007, 02:47 PM
#10
Re: Checkbox help
yes.. but in a work environment, be carefull that everyone will be allowed to modify the registry
id just go with the txt file.. simple. and since its not passwords etc.. who cares if someone looks? and.. if they delete it.. so it doesnt remember when loaded. but will reset on unload
JPnyc rocks!! (Just ask him!)
If u have your answer please go to the thread tools and click "Mark Thread Resolved"
-
Feb 1st, 2007, 02:49 PM
#11
Thread Starter
Hyperactive Member
Re: Checkbox help
please could you tell me how to do it.
Also what do you mean by everyone will be allowed to modify the registry. as i could disable regeditor
If your question is answered then mark your thread RESOLVED and give credit to whoever answered it.
If you fail, try and try again, its the only way to success.
-
Feb 1st, 2007, 02:52 PM
#12
Re: Checkbox help
oops.. one little word missing makes a big difference
Not every user may be able to modify registry. Like, an Admin can install an app & do stuff like that.. where as a reg user cant do anything like that. The avg user here cannot modify the reg, so your app may fail
JPnyc rocks!! (Just ask him!)
If u have your answer please go to the thread tools and click "Mark Thread Resolved"
-
Feb 1st, 2007, 02:54 PM
#13
Thread Starter
Hyperactive Member
Re: Checkbox help
my app dosent load on the avg user account but on the admin to set the restrictions for other users.
If your question is answered then mark your thread RESOLVED and give credit to whoever answered it.
If you fail, try and try again, its the only way to success.
-
Feb 1st, 2007, 02:56 PM
#14
Re: Checkbox help
Why not save them to a backend database table.
This is what we have been doing for all of our applications as the IS department here has the registry totally locked down.
In our database table, we have fields for the entries, as well as the user name, so we know what entry belongs to who.
-
Feb 1st, 2007, 03:00 PM
#15
Thread Starter
Hyperactive Member
Re: Checkbox help
pls reply Static as i dont know how to use databases,
thanks for your help anyway Hack, also the registry isnt locked on my admin account
If your question is answered then mark your thread RESOLVED and give credit to whoever answered it.
If you fail, try and try again, its the only way to success.
-
Feb 1st, 2007, 03:04 PM
#16
Re: Checkbox help
Look at Post #8.
I posted the code to do it. (but I like Hacks idea )
JPnyc rocks!! (Just ask him!)
If u have your answer please go to the thread tools and click "Mark Thread Resolved"
-
Feb 1st, 2007, 03:08 PM
#17
Thread Starter
Hyperactive Member
Re: Checkbox help
 Originally Posted by chris1990
thanks for all your help i have got a few options now.
Another question:
as the check boxes are applying restrictions using the registry, Is there away i can edit the keys i am using to apply them to certain users.
at the moment i am using the regkey below
HKEY_CURRENT_USER\SOFTWARE\Microsoft\
this way i have to log on to every user account and set the restrictions.
could i use something like this instead
Username\SOFTWARE\Microsoft\
so if it was me
Chris\SOFTWARE\Microsoft\
I ment when you replied yes, that you know how to do the question above
If your question is answered then mark your thread RESOLVED and give credit to whoever answered it.
If you fail, try and try again, its the only way to success.
-
Feb 1st, 2007, 04:20 PM
#18
Re: Checkbox help
gotcha.. well you can use API's but ive found this works well.
you'll have to tweak it to what you need
VB Code:
Private Function Registry_Read(Key_Path, Key_Name) As Variant
On Error Resume Next
Dim Registry As Object
Set Registry = CreateObject("WScript.Shell")
Registry_Read = Registry.RegRead(Key_Path & Key_Name)
End Function
Private Sub Registry_Write(Key_Path As String, Key_Name As String, Key_Value As Variant, Optional Key_Type As String)
On Error Resume Next
'Key Type list (Use within string, ex. "
' REG_DWORD")
'----------------
'REG_BINARY - This type stores the value
' as raw binary data. Most hardware compon
' ent information is stored as binary data
' , and can be displayed in an editor in h
' exadecimal format.
'REG_DWORD - This type represents the da
' ta by a four byte number and is commonly
' used for boolean values, such as "0" is
' disabled and "1" is enabled. Additionall
' y many parameters for device driver and
' services are this type, and can be displ
' ayed in REGEDT32 in binary, hexadecimal
' and decimal format, or in REGEDIT in hex
' adecimal and decimal format.
'REG_EXPAND_SZ - This type is an expanda
' ble data string that is string containin
' g a variable to be replaced when called
' by an application. For example, for the
' following value, the string "%SystemRoot
' %" will replaced by the actual location
' of the directory containing the Windows
' NT system files. (This type is only avai
' lable using an advanced registry editor
' such as REGEDT32)
'REG_MULTI_SZ - This type is a multiple
' string used to represent values that con
' tain lists or multiple values, each entr
' y is separated by a NULL character. (Thi
' s type is only available using an advanc
' ed registry editor such as REGEDT32)
'REG_SZ - This type is a standard string
' , used to represent human readable text
' values.
'Other data types not available through
' the standard registry editors include:
'REG_DWORD_LITTLE_ENDIAN - A 32-bit numb
' er in little-endian format.
'REG_DWORD_BIG_ENDIAN - A 32-bit number
' in big-endian format.
'REG_LINK - A Unicode symbolic link. Use
' d internally; applications should not us
' e this type.
'REG_NONE - No defined value type.
'REG_QWORD - A 64-bit number.
'REG_QWORD_LITTLE_ENDIAN - A 64-bit numb
' er in little-endian format.
'REG_RESOURCE_LIST - A device-driver res
' ource list.
Dim Registry As Object
Dim Registry_Value As Variant
Set Registry = CreateObject("WScript.Shell")
Registry_Value = Registry_Read(Key_Path, Key_Name)
If Key_Type = "" Then
'REG_SZ is the default.
Registry.RegWrite Key_Path & Key_Name, Key_Value
Else
Registry.RegWrite Key_Path & Key_Name, Key_Value, Key_Type
End If
End Sub
Private Sub Form_Activate()
'This is only an example of a registry entry.
MsgBox Registry_Read("HKEY_LOCAL_MACHINE\Software\Microsoft\Internet Explorer\", "W2kVersion")
Registry_Write "HKEY_LOCAL_MACHINE\SOFTWARE\MICROSOFT\WINDOWS\CURRENTVERSION\RUN\", "Test", 1, "REG_DWORD"
End Sub
JPnyc rocks!! (Just ask him!)
If u have your answer please go to the thread tools and click "Mark Thread Resolved"
-
Feb 1st, 2007, 04:36 PM
#19
Thread Starter
Hyperactive Member
Re: Checkbox help
I dont think you know what i mean.
I'll try to explain the best i can.
I am making a program so i can add restrictions to my pc's. Basicly you check the tick box and it modifys the regkey so it will disable it (e.g - distaskman = 1). I know how to modify and create regkeys. I have a listbox which lists the users on the pc.
What i hope to be able to do is set (distaskman=1) on 3 accounts and not disable it on 1 account, i can do it if log on as the other users because the regkey starts with HKEY_CURRENT_USER.
I would like to be able to set restrictions on other accounts from my account.
Here is an example of a different program which does it.http://www.softheap.com/newadminscreenshots.html
If your question is answered then mark your thread RESOLVED and give credit to whoever answered it.
If you fail, try and try again, its the only way to success.
-
Feb 1st, 2007, 04:40 PM
#20
Re: Checkbox help
so if you are logged in as "admin" you want to be able to hit tom, jim, and suzy's account and set their restrictions?
you would need to set keys in a general section of the reg.. one that all logons will see. then have your app read it and check the current user...
never done that.. its probably going to be a trial and error
JPnyc rocks!! (Just ask him!)
If u have your answer please go to the thread tools and click "Mark Thread Resolved"
-
Feb 1st, 2007, 04:41 PM
#21
Thread Starter
Hyperactive Member
Re: Checkbox help
k,
Thanks anyway
chris1990.
If your question is answered then mark your thread RESOLVED and give credit to whoever answered it.
If you fail, try and try again, its the only way to success.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|