07. januar 2004 - 00:53Der er
2 kommentarer og 1 løsning
hjælp til asp komponent - Sortering af array
Jeg har med VBScript brugt denne sub i min asp-kode, men for at forbedre ydelsen vil jeg gerne have lavet det til en .dll
Sub: Private Sub SortResultsByNumMatches(ByRef sarySearchResults, ByRef intTotalFilesFound)
'Dimension variables Dim intArrayGap 'Holds the part of the array being sorted Dim intIndexPosition 'Holds the Array index position being sorted Dim intTempResultsHold 'Temperary hold for the results if they need swapping array positions Dim intTempNumMatchesHold 'Temperary hold for the number of matches for the result if they need swapping array positions Dim intPassNumber 'Holds the pass number for the sort
'Loop round to sort each result found For intPassNumber = 1 To intTotalFilesFound
'Shortens the number of passes For intIndexPosition = 1 To (intTotalFilesFound - intPassNumber)
'If the Result being sorted hass less matches than the next result in the array then swap them If sarySearchResults(intIndexPosition, 2) < sarySearchResults((intIndexPosition + 1), 2) Then
'Place the Result being sorted in a temporary variable intTempResultsHold = sarySearchResults(intIndexPosition, 1)
'Place the Number of Matches for the result being sorted in a temporary variable intTempNumMatchesHold = sarySearchResults(intIndexPosition, 2)
'Do the array position swap
'Move the next Result with a higher match rate into the present array location sarySearchResults(intIndexPosition, 1) = sarySearchResults((intIndexPosition + 1), 1)
'Move the next Number of Matches for the result with a higher match rate into the present array location sarySearchResults(intIndexPosition, 2) = sarySearchResults((intIndexPosition + 1), 2)
'Move the Result from the teporary holding variable into the next array position sarySearchResults((intIndexPosition + 1), 1) = intTempResultsHold
'Move the Number of Matches for the result from the teporary holding variable into the next array position sarySearchResults((intIndexPosition + 1), 2) = intTempNumMatchesHold End If Next Next End Sub
Nogen som vil hjælpe mig med at få den lavet, jeg har kun arbejdet MEGET lidt med at lave asp-komponenter
Kommunerne har digitaliseret indgangen for borgerne. Men bag skærmen håndteres mange arbejdsgange stadig manuelt mellem systemer, mails og organisatoriske siloer.
ASP-Koden:____________________ set ar = server.createobject("SortArr.class1") ar.SortResultsByNumMatches(Results, FilesFound)
Fejlen:_______________________ Der kan ikke bruges parenteser ved kald af en Sub /istoria/default2.asp, line 1008, column 65 ar.SortResultsByNumMatches(sarySearchResults, intTotalFilesFound)
dll:__________________________ Option Explicit
Public Sub SortResultsByNumMatches(ByRef sarySearchResults, ByRef intTotalFilesFound)
'Dimension variables Dim intArrayGap 'Holds the part of the array being sorted Dim intIndexPosition 'Holds the Array index position being sorted Dim intTempResultsHold 'Temperary hold for the results if they need swapping array positions Dim intTempNumMatchesHold 'Temperary hold for the number of matches for the result if they need swapping array positions Dim intPassNumber 'Holds the pass number for the sort
'Loop round to sort each result found For intPassNumber = 1 To intTotalFilesFound
'Shortens the number of passes For intIndexPosition = 1 To (intTotalFilesFound - intPassNumber)
'If the Result being sorted hass less matches than the next result in the array then swap them If sarySearchResults(intIndexPosition, 2) < sarySearchResults((intIndexPosition + 1), 2) Then
'Place the Result being sorted in a temporary variable intTempResultsHold = sarySearchResults(intIndexPosition, 1)
'Place the Number of Matches for the result being sorted in a temporary variable intTempNumMatchesHold = sarySearchResults(intIndexPosition, 2)
'Do the array position swap
'Move the next Result with a higher match rate into the present array location sarySearchResults(intIndexPosition, 1) = sarySearchResults((intIndexPosition + 1), 1)
'Move the next Number of Matches for the result with a higher match rate into the present array location sarySearchResults(intIndexPosition, 2) = sarySearchResults((intIndexPosition + 1), 2)
'Move the Result from the teporary holding variable into the next array position sarySearchResults((intIndexPosition + 1), 1) = intTempResultsHold
'Move the Number of Matches for the result from the teporary holding variable into the next array position sarySearchResults((intIndexPosition + 1), 2) = intTempNumMatchesHold End If Next Next End Sub
Private Function searchHighlighter(ByVal strMessage, ByVal sarySearchWords)
Dim intHighlightLoopCounter 'Loop counter to loop through words and hightlight them Dim strTempMessage 'Temporary message store Dim lngMessagePosition 'Holds the message position Dim intHTMLTagLength 'Holds the length of the HTML tags Dim intSearchWordLength 'Holds the length of teh search word Dim blnTempUpdate 'Set to true if the temp message variable is updated
'Loop through each character in the post message For lngMessagePosition = 1 To Len(strMessage)
'Initilise for each pass blnTempUpdate = False
'If an HTML tag is found then move to the end of it so that no words in the HTML are highlighted If Mid(strMessage, lngMessagePosition, 1) = "<" Then
'Get the length of the HTML tag intHTMLTagLength = (InStr(lngMessagePosition, strMessage, ">", 1) - lngMessagePosition)
'Place the HTML tag back into the tempary message store strTempMessage = strTempMessage & Mid(strMessage, lngMessagePosition, intHTMLTagLength)
'Add the length of the HTML tag to the post message position variable lngMessagePosition = lngMessagePosition + intHTMLTagLength End If
'Loop through the search words to see if they are in the message post For intHighlightLoopCounter = 0 To UBound(sarySearchWords)
'If there is a search word in the array position check it If sarySearchWords(intHighlightLoopCounter) <> "" Then
'Get the length of the search word intSearchWordLength = Len(sarySearchWords(intHighlightLoopCounter))
'If the next XX characters are the same as the search word then highlight them If LCase(Mid(strMessage, lngMessagePosition, intSearchWordLength)) = LCase(sarySearchWords(intHighlightLoopCounter)) Then
'Highlight the search word strTempMessage = strTempMessage & "<b><strong>" & Mid(strMessage, lngMessagePosition, intSearchWordLength) & "</strong></b>"
'Add the length of the replaced search word to the post message position variable lngMessagePosition = lngMessagePosition + intSearchWordLength - 1
'Set the changed boolean to true blnTempUpdate = True End If End If Next
'If a search word is not highlighted then add the character from the post message being checked to the temp variable If blnTempUpdate = False Then strTempMessage = strTempMessage & Mid(strMessage, lngMessagePosition, 1) End If Next
'Return the function searchHighlighter = strTempMessage End Function
Prøv at gøre som fejlen siger - undlad parenteser:
ar.SortResultsByNumMatches Results, FilesFound
dna
Synes godt om
Ny brugerNybegynder
Din løsning...
Tilladte BB-code-tags: [b]fed[/b] [i]kursiv[/i] [u]understreget[/u] Web- og emailadresser omdannes automatisk til links. Der sættes "nofollow" på alle links.