用心做好每一件事情!

【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

 

posted @ 2014-05-13 20:35  无 影  阅读(1249)  评论(0编辑  收藏  举报
作者: Allen【QQ:96966 1314】 网名:无影 出处: http://www.cnblogs.com/allen0118/ 声明: 本文版权归作者和博客园共有!转载时必须保留此段声明,且在文章页面明显位置给出原文连接。