首页 > 代码库 > 【VB6笔记-02】从Command中获取链接参数

【VB6笔记-02】从Command中获取链接参数

Public Sub GetParameters()
                Dim Para As String
                
                Para = Command$()
                gstrUserID = GetCommandPara(Para, 1)
                gstrDSN = GetCommandPara(Para, 2)
                gstrSQLUserID = GetCommandPara(Para, 3)
                gstrPassWord = GetCommandPara(Para, 4)
                gstrServerName = GetCommandPara(Para, 5)
                gstrDataBaseName = GetCommandPara(Para, 6)
                gstrCompanyCode = GetCommandPara(Para, 7)
                
                gblnAllowAdd = IIf(UCase(GetCommandPara(Para, 8)) = "Y", True, False)
                gblnAllowEdit = IIf(UCase(GetCommandPara(Para, 9)) = "Y", True, False)
                gblnAllowDelete = IIf(UCase(GetCommandPara(Para, 10)) = "Y", True, False)
                gblnAllowSpecial = IIf(UCase(GetCommandPara(Para, 11)) = "Y", True, False)
End Sub


Public Function GetCommandPara(CommandStr As String, ParaNum As Integer) As String
        
            #If c_IssueVersion Then
                On Error GoTo GetCommandPara_Err
            #End If
            
            Dim OrigCmdStr As String
            Dim i As Integer
            Dim j As Integer
            ReDim PosArray(0 To 20)
            
            OrigCmdStr = RTrim$(LTrim$(CommandStr))
            PosArray(0) = 0
            j = 1
            
            For i = 1 To Len(OrigCmdStr)
                If Mid$(OrigCmdStr, i, 1) = "~" Then
                    PosArray(j) = i
                    j = j + 1
                End If
            Next i
            
            PosArray(j) = Len(OrigCmdStr) + 1
            GetCommandPara = Mid$(OrigCmdStr, PosArray(ParaNum - 1) + 1, PosArray(ParaNum) - PosArray(ParaNum - 1) - 1)
            
            Exit Function
GetCommandPara_Err:
            Call ErrHandler("The application can not get information to Login Server!", "Load Form")
End Function