vb.net中的一个组合函数

Function GetDirect(ByVal lCurrPos As Long, ByVal sSource As String, ByVal sFind As String, ByVal bPre As Boolean) As Integer

    '往前查找字符串
    Dim iLoop As Integer
    Dim iLength As Integer
    iLength = Len(sFind)

    Dim sTemp As String
    sTemp = ""

    While sFind <> sTemp
        sTemp = Mid(sSource, lCurrPos, iLength)
        If bPre = True Then
            lCurrPos = lCurrPos - 1
        Else
            lCurrPos = lCurrPos + 1
        End If
    End While
    GetDirect = lCurrPos

End Function
Function SubStringCount(ByVal sSource As String, ByVal sFind As String) As Integer

    SubStringCount = 0

    Dim iLenFind As Integer, iStart As Integer

    iLenFind = Len(sFind)
    iStart = 1

    Dim iPtr As Integer
    iPtr = 0

    Dim iPos As Integer
    iPos = InStr(iStart, sSource, sFind, CompareMethod.Text)
    If iPos > 1 Then
        SubStringCount = 1
        While (iPos)
            iPos = InStr(iPos + iLenFind, sSource, sFind, CompareMethod.Text)
            If iPos > 0 Then
                SubStringCount = SubStringCount + 1
            End If
        End While

    End If

End Function

Function GetTableValue(ByVal sTable As String, ByVal iRow As Integer, ByVal iCol As Integer) As String
    Dim iLoop As Integer
    Dim iPtr As Integer
    Dim iRowLeft As Integer
    Dim iRowRight As Integer
    Dim sRow As String
    Dim sCell As String

    iPtr = 1
    For iLoop = 1 To iRow
        iPtr = InStr(iPtr, sTable, "<tr", CompareMethod.Text)
        iPtr = iPtr + 3
    Next

    iRowLeft = iPtr - 3
    iRowRight = GetDirect(iRowLeft, sTable, "</tr>", False)
    sRow = Mid(sTable, iRowLeft, iRowRight - iRowLeft + 5 - 1)

    iPtr = 1
    For iLoop = 1 To iCol
        iPtr = InStr(iPtr, sRow, "<td", CompareMethod.Text)
        iPtr = iPtr + 3
    Next
    iRowLeft = iPtr - 3
    iRowRight = GetDirect(iRowLeft, sRow, "</td>", False)
    sCell = Mid(sRow, iRowLeft, iRowRight - iRowLeft + 5)


    iRowLeft = InStr(1, sCell, ">", CompareMethod.Text)
    iRowRight = InStr(iRowLeft, sCell, "</td>", CompareMethod.Text)

    sCell = Trim(Mid(sCell, iRowLeft + 1, iRowRight - iRowLeft - 1))
    GetTableValue = sCell

End Function 

评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值