📄 samples.bas
字号:
Attribute VB_Name = "Module1"
Option Explicit
' Function name: ReturnDataPath
' Return type: String
' Dependencies: Uses InStrL function
'
' Description: Returns the full path to the specified data directory.
'
' Args: dataDir - Data to return path for
'
Public Function ReturnDataPath(dataDir As String) As String
Dim sPath As String
Dim iLastPos As Integer
sPath = App.Path
iLastPos = InStrL(sPath, "\")
ReturnDataPath = Left(sPath, iLastPos) + "..\Data\" + dataDir
End Function
' Function name: InStrL
' Return type: Integer
' Dependencies: None
'
' Description: Returns the character position of the last occurrence
' of srchString in inString. If there is no match, 0 is
' returned. This provides the same functionality that VB's
' InStr function provides, except that it searches backwards.
'
' Args: inString - String to examine
' srchString - String to search for
'
Public Function InStrL(inString As String, srchString As String) As Integer
Dim iLastPos As Integer 'Set to 0 on initialization
' Check srchString -- a 0-length string will match every time
If Len(srchString) Then
' Set iLastPos to the last matching position
Dim iCurPos As Integer
Do
iLastPos = iCurPos
iCurPos = InStr(iCurPos + 1, inString, srchString, vbTextCompare)
Loop Until iCurPos = 0
End If
InStrL = iLastPos
End Function
' Function name: ConnectErrorMsg
' Return type: String
' Dependencies: None
'
' Description: Defines an appropriate error message for
' the Data Connection object, including
' errors from SDE (negative integers).
'
' Args: errNum - Integer representing ConnectionErrorConstant
' returned from DataConnection.ConnectError
'
Public Function ConnectErrorMsg(errNum As Integer) As String
Select Case errNum
'Generic Error Messages
Case moNoError: ConnectErrorMsg = "No Error"
Case moUnknownError: ConnectErrorMsg = "Unknown error"
Case moAccessDenied: ConnectErrorMsg = "Access denied"
Case moInvalidUser: ConnectErrorMsg = "Invalid user"
Case moNetworkTimeout: ConnectErrorMsg = "Network timeout"
Case moInvalidDatabase: ConnectErrorMsg = "Invalid database"
Case moTasksExceeded: ConnectErrorMsg = "Tasks exceeded"
Case moFileNotFound: ConnectErrorMsg = "File not found"
Case moInvalidDirectory: ConnectErrorMsg = "Invalid directory"
Case moHostUnknown: ConnectErrorMsg = "Unknown host"
'SDE Error Messages
Case moSE_FAILURE: ConnectErrorMsg = "Unspecified SDE error."
Case moSE_INVALID_LAYERINFO_OBJECT: ConnectErrorMsg = "LAYERINFO pointer not initialized."
Case moSE_NO_ANNOTATION: ConnectErrorMsg = "The given shape has no annotation"
Case moSE_FINISHED: ConnectErrorMsg = "Stream loading of shapes finished"
Case moSE_SDE_NOT_STARTED: ConnectErrorMsg = "SDE not started, cannot perform function"
Case moSE_UNCHANGED: ConnectErrorMsg = "The specified shape was left unchanged"
Case moSE_CONNECTIONS_EXCEEDED: ConnectErrorMsg = "The number of server connections is at maximum"
Case moSE_LOGIN_NOT_ALLOWED: ConnectErrorMsg = "IOMGR not accepting connection requests"
Case moSE_INVALID_USER: ConnectErrorMsg = "Cannot validate the specified user and password"
Case moSE_NET_FAILURE: ConnectErrorMsg = "Network i/o operation failed"
Case moSE_NET_TIMEOUT: ConnectErrorMsg = "Network i/o timeout"
Case moSE_OUT_OF_SVMEM: ConnectErrorMsg = "Server task cannot allocate needed memory"
Case moSE_OUT_OF_CLMEM: ConnectErrorMsg = "Client task cannot allocate needed memory"
Case moSE_OUT_OF_CONTEXT: ConnectErrorMsg = "Function call is out of context"
Case moSE_NO_ACCESS: ConnectErrorMsg = "No access to object"
Case moSE_TOO_MANY_LAYERS: ConnectErrorMsg = "Exceeded max_layers in giomgr.defs."
Case moSE_NO_LAYER_SPECIFIED: ConnectErrorMsg = "Missing layer specification"
Case moSE_LAYER_LOCKED: ConnectErrorMsg = "Specified layer is locked"
Case moSE_LAYER_EXISTS: ConnectErrorMsg = "Specified layer already exists"
Case moSE_LAYER_NOEXIST: ConnectErrorMsg = "Specified layer does not exist"
Case moSE_LAYER_INUSE: ConnectErrorMsg = "Specified layer is use by another user"
Case moSE_FID_NOEXIST: ConnectErrorMsg = "Specified shape (LAYER:FID) does not exist"
Case moSE_FID_EXISTS: ConnectErrorMsg = "Specified shape (LAYER:FID) exists"
Case moSE_LAYER_MISMATCH: ConnectErrorMsg = "Both layers must be the same for this"
Case moSE_NO_PERMISSIONS: ConnectErrorMsg = "No permission to perform operation"
Case moSE_INVALID_NOT_NULL: ConnectErrorMsg = "Column has not null constraint."
Case moSE_INVALID_SHAPE: ConnectErrorMsg = "Invalid shape, cannot be verified"
Case moSE_INVALID_LAYER_NUMBER: ConnectErrorMsg = "Map layer number out of range"
Case moSE_INVALID_ENTITY_TYPE: ConnectErrorMsg = "Invalid entity type"
Case moSE_INVALID_SEARCH_METHOD: ConnectErrorMsg = "Invalid search method"
Case moSE_INVALID_ETYPE_MASK: ConnectErrorMsg = "Invalid entity type mask"
Case moSE_BIND_CONFLICT: ConnectErrorMsg = "BIND/SET/GET mis-match"
Case moSE_INVALID_GRIDSIZE: ConnectErrorMsg = "Invalid grid size"
Case moSE_INVALID_LOCK_MODE: ConnectErrorMsg = "Invalid lock mode"
Case moSE_ETYPE_NOT_ALLOWED: ConnectErrorMsg = "Entity type of shape is not allowed in layer"
Case moSE_TOO_MANY_POINTS: ConnectErrorMsg = "Exceeded max points specified."
Case moSE_TABLE_NOEXIST: ConnectErrorMsg = "DBMS table does not exist"
Case moSE_ATTR_NOEXIST: ConnectErrorMsg = "Specified attribute column does not exist"
Case moSE_LICENSE_FAILURE: ConnectErrorMsg = "Underlying license manager problem."
Case moSE_OUT_OF_LICENSES: ConnectErrorMsg = "No more SDE licenses available."
Case moSE_INVALID_COLUMN_VALUE: ConnectErrorMsg = "Value exceeds valid range"
Case moSE_INVALID_WHERE: ConnectErrorMsg = "User specified where clause is invalid"
Case moSE_INVALID_SQL: ConnectErrorMsg = "User specified sql clause is invalid"
Case moSE_LOG_NOEXIST: ConnectErrorMsg = "Specified log file does not exist"
Case moSE_LOG_NOACCESS: ConnectErrorMsg = "Unable to access specified logfile"
Case moSE_LOG_NOTOPEN: ConnectErrorMsg = "Specified logfile is not open for i/o"
Case moSE_LOG_IO_ERROR: ConnectErrorMsg = "I/O error using logfile"
Case moSE_NO_SHAPES: ConnectErrorMsg = "No shapes selected or used in operation"
Case moSE_NO_LOCKS: ConnectErrorMsg = "No locks defined"
Case moSE_LOCK_CONFLICT: ConnectErrorMsg = "Lock request conflicts with another established lock"
Case moSE_OUT_OF_LOCKS: ConnectErrorMsg = "Maximum locks allowed by system are in use"
Case moSE_DB_IO_ERROR: ConnectErrorMsg = "Database level i/o error occurred"
Case moSE_STREAM_IN_PROGRESS: ConnectErrorMsg = "Shape/fid stream not finished, can not execute"
Case moSE_INVALID_COLUMN_TYPE: ConnectErrorMsg = "Invalid column data type"
Case moSE_TOPO_ERROR: ConnectErrorMsg = "Topological integrity error"
Case moSE_ATTR_CONV_ERROR: ConnectErrorMsg = "Attribute conversion error"
Case moSE_INVALID_COLUMN_DEF: ConnectErrorMsg = "Invalid column definition"
Case moSE_INVALID_SHAPE_BUF_SIZE: ConnectErrorMsg = "Invalid shape array buffer size"
Case moSE_INVALID_ENVELOPE: ConnectErrorMsg = "Envelope is null, has negative values or min > max"
Case moSE_TEMP_IO_ERROR: ConnectErrorMsg = "Temp file i/o error, can not open or ran out of disk"
Case moSE_GSIZE_TOO_SMALL: ConnectErrorMsg = "Spatial index grid size is too small"
Case moSE_LICENSE_EXPIRED: ConnectErrorMsg = "SDE run-time license has expired, no logins allowed"
Case moSE_TABLE_EXISTS: ConnectErrorMsg = "DBMS table exists"
Case moSE_INDEX_EXISTS: ConnectErrorMsg = "Index with the specified name already exists"
Case moSE_INDEX_NOEXIST: ConnectErrorMsg = "Index with the specified name does not exist"
Case moSE_INVALID_POINTER: ConnectErrorMsg = "Specified pointer value is null or invalid"
Case moSE_INVALID_PARAM_VALUE: ConnectErrorMsg = "Specified parameter value is invalid"
Case moSE_ALL_SLIVERS: ConnectErrorMsg = "Sliver factor caused all results to be slivers"
Case moSE_TRANS_IN_PROGRESS: ConnectErrorMsg = "User specified transaction in progress"
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -