不会吧
比如为了保存按钮得标题
dim bln as boolean
private sub command1_click()
if bln then
  command1.caption="x"
  else
  command1.caption="0"
end if
bln=not bln
propertychanged
end subprivate sub userdocument_writeproperties(propbag as propertybag)
 propbag.writeproperty "command*"
end sub
private sub userdocument_readproperties(propbag as propertybag)
 command1.caption=propbag.readproperty("command&")
end sub

解决方案 »

  1.   

    原程序如下,达人们帮我看看啊。
    Private ser As String
    Private user As String
    Private pwd As String
    Private db As String
    Private cn As ADODB.ConnectionPublic Property Let Server(ByVal str As String)
      ser = str
      PropertyChanged "Server"
    End PropertyPublic Property Get Server() As String
      Server = ser
    End PropertyPublic Property Let SerUid(ByVal str As String)
      user = str
      PropertyChanged "seruid"
    End PropertyPublic Property Get SerUid() As String
      SerUid = user
    End PropertyPublic Property Let SerPwd(ByVal str As String)
      pwd = str
      PropertyChanged "serpwd"
    End PropertyPublic Property Get SerPwd() As String
      SerPwd = pwd
    End PropertyPublic Property Let DataBase(ByVal str As String)
      db = str
      PropertyChanged "Database"
    End PropertyPublic Property Get DataBase() As String
      DataBase = db
    End PropertyPrivate Sub Class_ReadProperties(PropBag As PropertyBag)
      With PropBag
       ser = .ReadProperty("Server")
       user = .ReadProperty("SerUid")
       pwd = .ReadProperty("SerPwd")
       db = .ReadProperty("DataBase")
      End With
    End SubPrivate Sub Class_Terminate()
      Set cn = Nothing
    End SubPrivate Sub Class_WriteProperties(PropBag As PropertyBag)
      With PropBag
        .WriteProperty "Server", ser
        .WriteProperty "SerUid", user
        .WriteProperty "SerPwd", pwd
        .WriteProperty "DataBase", db
      End With
    End SubPublic Property Get SerCon() As ADODB.Connection
      Set cn = New ADODB.Connection
      cn.Open "Provider=SQLOLEDB.1;Data Source=" & ser & ";Initial Catalog=" & db, user, pwd
      Set SerCon = cn
    End Property