实现了默认参数、试用限制、软件注册等功能
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
本站仅提供存储服务,所有内容均由用户发布,如发现有害或侵权内容,请
点击举报。