Public Function gettime() As String Dim cn As New ADODB.Connection Dim cmd As New ADODB.Command Dim rst As New ADODB.Recordset On Error GoTo ErrPro cn.ConnectionString = "driver={SQL Server};" & _ "server=10.163.10.3;uid=trace;pwd=traceaeclmis;database=master" cn.ConnectionTimeout = 300 cn.Open cmd.ActiveConnection = cn cmd.CommandText = "select convert(char(20),getdate(),120) as sys_date" 'cmd.ActiveConnection = cn Set rst = cmd.Execute gettime = rst(0) rst.Close cn.Close Exit Function ErrPro: gettime = Format(Now(), "YYYY-mm-DD HH:mm:ss") End Function http://www.m5home.com/bbs/dispbbs.asp?boardid=34&Id=1690 这个通过标准dll模板生成dll以后,给别的VB程序调用只 能返回首字母,不知道怎么搞的。 大侠指点 我的引用函数是下面的,只返回一个‘2’: Private Declare Function gettime Lib "TestDLL0912.dll" () As StringPrivate Sub cmdExit_Click() End End SubPrivate Sub Command1_Click() 'Dim d, dd As String 'd = Format(gettime(), "yyyy-MM-dd HH:mm:ss") 'dd = getdate() Text1.Text = gettime() 'Format(gettime(), "yyyy-MM-dd HH:mm:ss") 'Dim d As Date 'd = gettime() 'Text1.Text = Format(d, "yyyy-MM-dd HH:mm:ss")End Sub
Dim cn As New ADODB.Connection
Dim cmd As New ADODB.Command
Dim rst As New ADODB.Recordset On Error GoTo ErrPro cn.ConnectionString = "driver={SQL Server};" & _
"server=10.163.10.3;uid=trace;pwd=traceaeclmis;database=master"
cn.ConnectionTimeout = 300
cn.Open
cmd.ActiveConnection = cn
cmd.CommandText = "select convert(char(20),getdate(),120) as sys_date"
'cmd.ActiveConnection = cn
Set rst = cmd.Execute
gettime = rst(0)
rst.Close
cn.Close
Exit Function ErrPro:
gettime = Format(Now(), "YYYY-mm-DD HH:mm:ss")
End Function http://www.m5home.com/bbs/dispbbs.asp?boardid=34&Id=1690 这个通过标准dll模板生成dll以后,给别的VB程序调用只 能返回首字母,不知道怎么搞的。
大侠指点
我的引用函数是下面的,只返回一个‘2’:
Private Declare Function gettime Lib "TestDLL0912.dll" () As StringPrivate Sub cmdExit_Click()
End
End SubPrivate Sub Command1_Click()
'Dim d, dd As String
'd = Format(gettime(), "yyyy-MM-dd HH:mm:ss")
'dd = getdate()
Text1.Text = gettime() 'Format(gettime(), "yyyy-MM-dd HH:mm:ss")
'Dim d As Date
'd = gettime()
'Text1.Text = Format(d, "yyyy-MM-dd HH:mm:ss")End Sub