Programación General > Visual Basic 6.0 e inferiores

 Net Xpider Un Programanita

(1/1)

hitman47:
¡hola! que tal foristas mi pregunta es la siguiente alguno de ustedes conoce la forma de hacer que los programas en visual basic manejen la memoria bien y no se congelen? lo que pasa es que estoy desarrollando un programa que busca en muchisimos archivos txt sus codigos y los analiza. pero este se tildea cuando son mas de 3 archivos, para minimizarlo demora un monton para moverlo en pantalla tambien etc. al agragarle el doevents a el ciclo mejoro el rendimiento del programa pero no se que mas hacer.  no se si quizas con multithreading mejore. y en q web aprendo a usarlo bien.

salu2!

ArKaNtOs:
Puedes dejar parte de tu codigo critico plz?, para checar que se le puede optimizar ;)

hitman47:
intente subir el archivo adjunto pero no me dejo
este es algo del codigo:

--- Código: Text --- Dim sitioweb As StringDim done As Integer 'sites scannedDim halt As Boolean, restart As Boolean Sub Startspider()'funcion principal del programaDim i As Integer 'indexDim siteanalisis As String 'string containig the site analisis of adsensesMsgBox "sites to scan " & List1.ListCountFor i = done To List1.ListCountDoEvents 'le puse este doevents pa q no c trabesitioweb = List1.List(i - 1) 'obtengo un sitio web de la lista cargadaText2.Text = sitiowebrtf.Text = OpenURL(sitioweb) 'obtengo el codigo html del sitio webIf halt = True Then 'maneja el pausa de la aplicaciondone = i 'guarda el estado donde queda n pausaExit SubEnd Ifsiteanalisis = analizepage(rtf.Text, i) 'mando ha buscar el numeroc pub del google adsenseIf siteanalisis <> "" Then Print #2, siteanalisissiteanalisis = ""Label3.Caption = CStr(Format$(i / List1.ListCount * 100, "###.##")) & "%"'Call SlowDown(1000)Next iClose #2Text2.Text = "C:\spiderN.txt"MsgBox "Pub numbers Seaarch finish!", vbInformationEnd Sub Function analizepage(ByVal html As String, ByVal i As Integer) As StringDim s, e As Variant 'positionDim pub As String 'pub of google adsenseIf InStr(html, "google_ad_client = ") > 0 Thens = InStr(InStr(html, "google_ad_client = "), html, "pub-")e = InStr(s + 4, html, ";") - 3pub = "G,"pub = pub & Mid(html, s + 4, e - s - 2)pub = pub & "," & List1.List(i - 1)analizepage = pubEnd IfIf InStr("yahoo_ad_client = """"pub-", html) Then 'yahhooEnd IfEnd Function Private Function OpenURL(ByVal sUrl As String) As String'****************************************************'PURPOSE:       Returns Contents (including all HTML) from'               a web page'PARAMETER:     sURL (e.g., http://www33.websamba.com/iglesiadc)'RETURN VALUE:  Contents of requested page, or'               empty string if sURL is not available'COMMENTS:  This is an alternative to using the Internet Transfer'           Control 's OpenURL method.  That control has a bug'           Whereby not all the contents of the page will be'           returned in certain circumstances'*****************************************************     Dim hOpen               As Long    Dim hOpenUrl            As Long    Dim bDoLoop             As Boolean    Dim bRet                As Boolean    Dim sReadBuffer         As String * 2048    Dim lNumberOfBytesRead  As Long    Dim sBuffer             As String hOpen = InternetOpen(scUserAgent, INTERNET_OPEN_TYPE_PRECONFIG, _    vbNullString, vbNullString, 0) hOpenUrl = InternetOpenUrl(hOpen, sUrl, vbNullString, 0, _   INTERNET_FLAG_RELOAD, 0)     bDoLoop = True    While bDoLoop    DoEvents 'le puse este doevents pa q no c trabe         sReadBuffer = vbNullString        bRet = InternetReadFile(hOpenUrl, sReadBuffer, _           Len(sReadBuffer), lNumberOfBytesRead)        sBuffer = sBuffer & Left$(sReadBuffer, _             lNumberOfBytesRead)        If Not CBool(lNumberOfBytesRead) Then bDoLoop = False    Wend          If hOpenUrl <> 0 Then InternetCloseHandle (hOpenUrl)    If hOpen <> 0 Then InternetCloseHandle (hOpen)    OpenURL = sBuffer End Function 
la funcion  OpenURL me devuelve el codigo html de un website x en realidad iba a usar el control inet del vb pero tiene un bug q no te devuelve todo el codigo html de una pagina.

a otra cosa si voy a realizar un analizador de html que lea links, mailto, center, font etc. las d+ etiquetas con que es mejor hacerlo. con el DOM MSHTML.DLL o mi propio HTML parser con instr ciclos y demas codigo?gracias salu2!

Navegación

[0] Índice de Mensajes

Ir a la versión completa