CADsite forum

AutoCAD => VBA => Topic gestart door: martijn op wo 20 01 2010, 17:02:24

Titel: Checkbox aan laten staan
Bericht door: martijn op wo 20 01 2010, 17:02:24
Ja ja, weer even aan het tobben met het VBA programmeren.

Nu heb ik hetvolgende. Op een formulier heb ik een checkbox gezet welke bepaald of het formulier na het plaatsen van een blok terug moet komen of niet.
Als je eruit gaat, wordt het formulier ge Unload en ben je de instelling van de checkbox ook weer kwijt. Kun je ergens instellen dat hij dit moet bewaren of ergens anders deze instelling op moet halen?

Martijn
Titel: Re:Checkbox aan laten staan
Bericht door: sschevers op do 21 01 2010, 09:20:21
Martijn,

Dit soort instellingen kun je opslaan in de registry. Met het command SaveSetting sla je waardes op en met Getsetting haal je de waardes weer op uit de registry. Zie onderstaande uitleg vanuit de help

GetSetting Function
     

Returns a key setting value from an application's entry in the Windows registry or (on the Macintosh) information in the application's initialization file.

Syntax

GetSetting(appname, section, key[, default])

The GetSetting function syntax has these named arguments:

Part Description
appname Required. String expression containing the name of the application or project whose key setting is requested. On the Macintosh, this is the filename of the initialization file in the Preferences folder in the System folder.
section Required. String expression containing the name of the section where the key setting is found.
key Required. String expression containing the name of the key setting to return.
default Optional. Expression containing the value to return if no value is set in the key setting. If omitted, default is assumed to be a zero-length string ("").



Remarks

If any of the items named in the GetSetting arguments do not exist, GetSetting returns the value of default.


SaveSetting Statement
     

Saves or creates an application entry in the application's entry in the Windows registry or (on the Macintosh) information in the application's initialization file.

Syntax

SaveSetting appname, section, key, setting

The SaveSetting statement syntax has these named arguments:

Part Description
appname Required. String expression containing the name of the application or project to which the setting applies. On the Macintosh, this is the filename of the initialization file in the Preferences folder in the System folder.
section Required. String expression containing the name of the section where the key setting is being saved.
key Required. String expression containing the name of the key setting being saved.
setting Required. Expression containing the value that key is being set to.



Remarks

An error occurs if the key setting can't be saved for any reason.

greetz Stephan
Titel: Re:Checkbox aan laten staan
Bericht door: martijn op wo 27 01 2010, 09:28:38
Da's iets ingewikkelder dan ik gehoopt had, maar super bedankt ik ga er vanmiddag even mee stoeien.
Titel: Re:Checkbox aan laten staan
Bericht door: EddyBeerke op do 29 04 2010, 22:24:18
Je kunt ook een globale variable maken.
Pas als je acad afsluit gaat de instelling verloren.
Als dat niet erg is dan lijkt mij dat je beter van het register van windows af moet blijven.
Een andere optie om iets dergelijks te bewaren is bv een INI bestand waarin je de waarde opslaat en voor later gebruik weer kunt lezen.
Titel: Re:Checkbox aan laten staan
Bericht door: stonie op za 25 12 2010, 11:38:08
Misschien een beetje laat, maar dan toch voor de volgende.
In de opgeslagen tekening zitten standaard 5 USERI variabelen.
Deze zijn te gebruiken om later weer uit te lezen, dus misschien een optie voor jouw probleem ?

Sub test()
'uitlezen
MsgBox ThisDocument.GetVariable("USERI5")
'invullen
ThisDocument.SetVariable "USERI5", 1
End Sub

Stonie