+ -
当前位置:首页 → 问答吧 → 求高人指点...VB转delphi的.哭一天了.

求高人指点...VB转delphi的.哭一天了.

时间:2011-11-15

来源:互联网

新手刚学了俩月delphi,接触了个vb转delphi的代码:

Public Function ExeRecordset(ByVal sql As String, m_con As ADODB.Connection, Optional nCursorLocation As CursorLocationEnum = adUseClient, Optional nCursorType As CursorTypeEnum = adOpenDynamic, Optional nLockType As LockTypeEnum = adLockOptimistic) As ADODB.Recordset
  Dim mRs As ADODB.Recordset
  Set mRs = New ADODB.Recordset
  mRs.CursorLocation = nCursorLocation
  mRs.Open sql, m_con, nCursorType, nLockType
  Set ExeRecordset = mRs
End Function
真心求教,这段运行查询,返回记录集的代码.定义中的Optional nCursorLocation As CursorLocationEnum = adUseClient, Optional nCursorType As CursorTypeEnum = adOpenDynamic, Optional nLockType As LockTypeEnum = adLockOptimistic 这一段我不知道在delphi中该怎么写,作为可选返回参数来说这些有写的必要吗?

还有这些,我不太理解函数名(GetDictory)套进函数本身是的做法.为什么不用(SourceDictory),虚心求教,在VB区发的没人理...
Private Function GetDictory(SourceDictory As String) As String
  GetDictory = Mid(SourceDictory, 1, Len(SourceDictory) - 1)
   
  Do While InStr(1, GetDictory, "\") <> 0
  GetDictory = Mid(GetDictory, InStr(1, GetDictory, "\") + 1)
  Loop
End Function

作者: whosseven   发布时间: 2011-11-15

看上面代碼,在DELPHI是數據庫編程的入門級。如果VB熟悉的話,就先找本DELPHI的數據庫入門看看。如果VB也不熟,那就別轉了。

作者: Oraclers   发布时间: 2011-11-15