打开APP
userphoto
未登录

开通VIP,畅享免费电子书等14项超值服

开通VIP
VBA操作注册表
实现了默认参数、试用限制、软件注册等功能 
Private Sub Workbook_Open() 
  servername = GetSetting(appname:="UfoInExcel", section:="MySection", key:="MyServer") 
  sapwd = GetSetting(appname:="UfoInExcel", section:="MySection", key:="MyPwd") 

   If servername = "" Then 
      UserForm1.Show 
   End If 
End Sub 

Private Sub CommandButton1_Click() 
On Error GoTo ErrorHandler 
    Set conn = New ADODB.Connection 
    With conn 
        .ConnectionString = "driver={SQL Server};server=" & ComboBox1.Value & ";uid=sa;" & _ 
                            "pwd=" & TextBox1.Value & ";database=UFDATA_" & ComboBox2.Value & _ 
                            "_" & ComboBox3.Value 
        .Open 
    End With 
    conn.Close 
    Set conn = Nothing 
         
ServerName1 = ComboBox1.Value 
SaveSetting "UfoInExcel", "MySection", "MyServer", ServerName1 

sapwd1 = TextBox1.Value 
SaveSetting "UfoInExcel", "MySection", "MyPwd", sapwd1 

ZT1 = ComboBox2.Value 
SaveSetting "UfoInExcel", "MySection", "MyZt", ZT1 

ZTND1 = ComboBox3.Value 
SaveSetting "UfoInExcel", "MySection", "MyZtnd", ZTND1 


    Unload UserForm1 
    MsgBox "设置成功!" 
        Exit Sub 
ErrorHandler: 
    MsgBox "错误!请检查服务器设置!" & Chr(10) & Chr(10) & _ 
           "东学西读,lhq001@hotmail.com", vbOKOnly + 64, "出错啦!" 
    Exit Sub 
End Sub 


Public Function GetConnStr() 
    GetConnStr = "driver={SQL Server};server=" & GetSetting(appname:="UfoInExcel", section:="MySection", key:="MyServer") & ";uid=sa;pwd=" & GetSetting(appname:="UfoInExcel", section:="MySection", key:="MyPwd") 
End Function 

Function fs(科目代码, 月份, Optional 借或贷 As String, Optional 年或月 As String = "月", Optional 年度 As String, Optional 帐套号 As String, Optional 包含未记帐 As String = "Y", Optional 辅助核算方式 As String, Optional 辅助核算编码 As String) 
If 年度 > Year(Date) Then Exit Function 
If 年度 = Year(Date) And 月份 >= Month(Date) Then Exit Function 
Dim csqlstr As String 
    fs = 0 
    If Trim(科目代码) = "" Then Exit Function 
    If Trim(年或月) = "" Then Exit Function 
    If Trim(月份) = "" Then Exit Function 
    If Trim(年度) = "" Then 
    年度 = GetSetting(appname:="UfoInExcel", section:="MySection", key:="MyZtnd") 
    End If 
    If Trim(帐套号) = "" Then 
    帐套号 = GetSetting(appname:="UfoInExcel", section:="MySection", key:="MyZt") 
    End If 

    ... 
End function
本站仅提供存储服务,所有内容均由用户发布,如发现有害或侵权内容,请点击举报
打开APP,阅读全文并永久保存 查看更多类似文章
猜你喜欢
类似文章
【热】打开小程序,算一算2024你的财运
得到汉字的拼音首字母
VB实例教程之操作Access数据库
用VB编写监视指定进程的程序
VB读写配置文件(ini)
使用GetSetting函数和SaveSetting函数读写注册表设置
最全防止sql注入方法
更多类似文章 >>
生活服务
热点新闻
分享 收藏 导长图 关注 下载文章
绑定账号成功
后续可登录账号畅享VIP特权!
如果VIP功能使用有故障,
可点击这里联系客服!

联系客服