Results 1 to 21 of 21

Thread: [RESOLVED] Checkbox help

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Sep 2006
    Location
    Greater Manchester, UK
    Posts
    476

    Resolved [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.

  2. #2
    Hyperactive Member
    Join Date
    Oct 2006
    Posts
    419

    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!

  3. #3

    Thread Starter
    Hyperactive Member
    Join Date
    Sep 2006
    Location
    Greater Manchester, UK
    Posts
    476

    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.

  4. #4
    Member
    Join Date
    Jan 2007
    Posts
    51

    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

  5. #5

    Thread Starter
    Hyperactive Member
    Join Date
    Sep 2006
    Location
    Greater Manchester, UK
    Posts
    476

    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.

  6. #6

    Thread Starter
    Hyperactive Member
    Join Date
    Sep 2006
    Location
    Greater Manchester, UK
    Posts
    476

    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.

  7. #7
    Hyperactive Member
    Join Date
    Oct 2006
    Posts
    419

    Re: Checkbox help

    to save use something like:

    VB Code:
    1. 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:
    1. 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!

  8. #8
    PowerPoster Static's Avatar
    Join Date
    Oct 2000
    Location
    Rochester, NY
    Posts
    9,390

    Re: Checkbox help

    VB Code:
    1. Private Sub Form_Load()
    2.     Dim tmp() As String
    3.     Dim chks() As String
    4.     If Len(Dir(App.paht & "\checks.dat")) <> 0 Then
    5.         Open App.Path & "\checks.dat" For Input As #1
    6.             tmp = Split(Input(LOF(1), 1), vbCrLf)
    7.         Close #1
    8.         For X = 0 To UBound(tmp)
    9.             If tmp(X) <> "" Then
    10.                 chks = Split(tmp(X), ",")
    11.                 Me.Controls(chks(0)).Value = chks(1)
    12.             End If
    13.         Next
    14.     End If
    15. End Sub
    16.  
    17. Private Sub Form_Unload(Cancel As Integer)
    18.     Dim ctl As Control
    19.     Open App.Path & "\checks.dat" For Output As #1
    20.         For Each ctl In Me.Controls
    21.             If TypeOf ctl Is CheckBox Then
    22.                 Print #1, ctl.Name & "," & ctl.Value
    23.             End If
    24.         Next
    25.     Close #1
    26. End Sub
    JPnyc rocks!! (Just ask him!)
    If u have your answer please go to the thread tools and click "Mark Thread Resolved"

  9. #9

    Thread Starter
    Hyperactive Member
    Join Date
    Sep 2006
    Location
    Greater Manchester, UK
    Posts
    476

    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.

  10. #10
    PowerPoster Static's Avatar
    Join Date
    Oct 2000
    Location
    Rochester, NY
    Posts
    9,390

    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"

  11. #11

    Thread Starter
    Hyperactive Member
    Join Date
    Sep 2006
    Location
    Greater Manchester, UK
    Posts
    476

    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.

  12. #12
    PowerPoster Static's Avatar
    Join Date
    Oct 2000
    Location
    Rochester, NY
    Posts
    9,390

    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"

  13. #13

    Thread Starter
    Hyperactive Member
    Join Date
    Sep 2006
    Location
    Greater Manchester, UK
    Posts
    476

    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.

  14. #14
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    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.

  15. #15

    Thread Starter
    Hyperactive Member
    Join Date
    Sep 2006
    Location
    Greater Manchester, UK
    Posts
    476

    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.

  16. #16
    PowerPoster Static's Avatar
    Join Date
    Oct 2000
    Location
    Rochester, NY
    Posts
    9,390

    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"

  17. #17

    Thread Starter
    Hyperactive Member
    Join Date
    Sep 2006
    Location
    Greater Manchester, UK
    Posts
    476

    Re: Checkbox help

    Quote 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.

  18. #18
    PowerPoster Static's Avatar
    Join Date
    Oct 2000
    Location
    Rochester, NY
    Posts
    9,390

    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:
    1. Private Function Registry_Read(Key_Path, Key_Name) As Variant
    2.     On Error Resume Next
    3.     Dim Registry As Object
    4.     Set Registry = CreateObject("WScript.Shell")
    5.     Registry_Read = Registry.RegRead(Key_Path & Key_Name)
    6. End Function
    7.  
    8. Private Sub Registry_Write(Key_Path As String, Key_Name As String, Key_Value As Variant, Optional Key_Type As String)
    9.     On Error Resume Next
    10.     'Key Type list (Use within string, ex. "
    11.     '     REG_DWORD")
    12.     '----------------
    13.     'REG_BINARY - This type stores the value
    14.     '     as raw binary data. Most hardware compon
    15.     '     ent information is stored as binary data
    16.     '     , and can be displayed in an editor in h
    17.     '     exadecimal format.
    18.     'REG_DWORD - This type represents the da
    19.     '     ta by a four byte number and is commonly
    20.     '     used for boolean values, such as "0" is
    21.     '     disabled and "1" is enabled. Additionall
    22.     '     y many parameters for device driver and
    23.     '     services are this type, and can be displ
    24.     '     ayed in REGEDT32 in binary, hexadecimal
    25.     '     and decimal format, or in REGEDIT in hex
    26.     '     adecimal and decimal format.
    27.     'REG_EXPAND_SZ - This type is an expanda
    28.     '     ble data string that is string containin
    29.     '     g a variable to be replaced when called
    30.     '     by an application. For example, for the
    31.     '     following value, the string "%SystemRoot
    32.     '     %" will replaced by the actual location
    33.     '     of the directory containing the Windows
    34.     '     NT system files. (This type is only avai
    35.     '     lable using an advanced registry editor
    36.     '     such as REGEDT32)
    37.     'REG_MULTI_SZ - This type is a multiple
    38.     '     string used to represent values that con
    39.     '     tain lists or multiple values, each entr
    40.     '     y is separated by a NULL character. (Thi
    41.     '     s type is only available using an advanc
    42.     '     ed registry editor such as REGEDT32)
    43.     'REG_SZ - This type is a standard string
    44.     '     , used to represent human readable text
    45.     '     values.
    46.     'Other data types not available through
    47.     '     the standard registry editors include:
    48.     'REG_DWORD_LITTLE_ENDIAN - A 32-bit numb
    49.     '     er in little-endian format.
    50.     'REG_DWORD_BIG_ENDIAN - A 32-bit number
    51.     '     in big-endian format.
    52.     'REG_LINK - A Unicode symbolic link. Use
    53.     '     d internally; applications should not us
    54.     '     e this type.
    55.     'REG_NONE - No defined value type.
    56.     'REG_QWORD - A 64-bit number.
    57.     'REG_QWORD_LITTLE_ENDIAN - A 64-bit numb
    58.     '     er in little-endian format.
    59.     'REG_RESOURCE_LIST - A device-driver res
    60.     '     ource list.
    61.     Dim Registry As Object
    62.     Dim Registry_Value As Variant
    63.     Set Registry = CreateObject("WScript.Shell")
    64.     Registry_Value = Registry_Read(Key_Path, Key_Name)
    65.     If Key_Type = "" Then
    66.         'REG_SZ is the default.
    67.         Registry.RegWrite Key_Path & Key_Name, Key_Value
    68.     Else
    69.         Registry.RegWrite Key_Path & Key_Name, Key_Value, Key_Type
    70.     End If
    71. End Sub
    72.  
    73. Private Sub Form_Activate()
    74.     'This is only an example of a registry entry.
    75.     MsgBox Registry_Read("HKEY_LOCAL_MACHINE\Software\Microsoft\Internet Explorer\", "W2kVersion")
    76.     Registry_Write "HKEY_LOCAL_MACHINE\SOFTWARE\MICROSOFT\WINDOWS\CURRENTVERSION\RUN\", "Test", 1, "REG_DWORD"
    77. End Sub
    JPnyc rocks!! (Just ask him!)
    If u have your answer please go to the thread tools and click "Mark Thread Resolved"

  19. #19

    Thread Starter
    Hyperactive Member
    Join Date
    Sep 2006
    Location
    Greater Manchester, UK
    Posts
    476

    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.

  20. #20
    PowerPoster Static's Avatar
    Join Date
    Oct 2000
    Location
    Rochester, NY
    Posts
    9,390

    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"

  21. #21

    Thread Starter
    Hyperactive Member
    Join Date
    Sep 2006
    Location
    Greater Manchester, UK
    Posts
    476

    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
  •  



Click Here to Expand Forum to Full Width