is anything better than MSINET.OCX?
is anything better than MSINET.OCX?
is anything better than MSINET.OCX?
is anything better than MSINET.OCX?
is anything better than MSINET.OCX?
is anything better than MSINET.OCX? is anything better than MSINET.OCX? is anything better than MSINET.OCX? is anything better than MSINET.OCX? is anything better than MSINET.OCX? is anything better than MSINET.OCX? is anything better than MSINET.OCX? is anything better than MSINET.OCX?
is anything better than MSINET.OCX? is anything better than MSINET.OCX?
is anything better than MSINET.OCX?
Go Back  Xtreme Visual Basic Talk > > > is anything better than MSINET.OCX?


Reply
 
Thread Tools Display Modes
  #1  
Old 08-18-2013, 02:11 PM
flyguille flyguille is offline
Newcomer
 
Join Date: Apr 2010
Location: Argentinia
Posts: 14
Default is anything better than MSINET.OCX?


I have several installers that works online so the same installer allways installs the latest version.

These installers uses the msinet.ocx component in way to download individual files from a webserver, the problem seems that the msinet is like not capable to complete downloads when the PING is too high, like, the webserver is in a hosting at Argentinia, so it works great for all argentinian, but mexicans have problems to upgrade, peruvians too, in the msinet.ocx side the downloads FAILS and it retry and retry, like 10 20 times for just download a 3MB file, by example.

So, I asked to one mexican, ok download the file with Chrome, here is the URL, and copy/past the file, with the chrome or any other browser they can download perfectly in the first try.

But the msinet object is stuck retrying that specific downloads. And I don't know what is happening, I already notice that you must insert a DoEvents in the receiving procedure or it will not download files larger than 80K.

I also, ripped the latest MSINET.OCX from vb6 sp6 (service pack), because the original that comes with VB5 is tooooo buggy and is a headache.

I also implements length comprobations and md5 comprobations to make sure that the download is COMPLETED and not taken as complete but Incomplete in REAL (another bug from MSINET).

So all it downloads is signed, as a way to implement security again webserver infections, etc.

Now, there is other object that works better? or msinet has another trick that I don't know?.
Reply With Quote
  #2  
Old 08-19-2013, 12:57 PM
Cerian Knight's Avatar
Cerian Knightis anything better than MSINET.OCX? Cerian Knight is offline
Polymath (in disciplina)

Super Moderator
* Expert *
 
Join Date: May 2004
Location: Michigan
Posts: 4,193
Default

However, most issues with MSINET reliability probably revolve around whether you are using Execute/GetChunk (best practice with large files) or just OpenURL (perhaps more subject to timeouts).

Winsock API (MsInet is a wrapper for it, I think) might possibly be more reliable, but I've used Inet (with either GetChunk or OpenURL) with success.
__________________
I got all the answers wrong on the GLAT, apparently even #9 (where I put a period in the middle of the box and labeled it 'singularity ripe for rapid inflation').
Reply With Quote
  #3  
Old 08-19-2013, 03:22 PM
flyguille flyguille is offline
Newcomer
 
Join Date: Apr 2010
Location: Argentinia
Posts: 14
Default

Quote:
Originally Posted by Cerian Knight View Post
However, most issues with MSINET reliability probably revolve around whether you are using Execute/GetChunk (best practice with large files) or just OpenURL (perhaps more subject to timeouts).

Winsock API (MsInet is a wrapper for it, I think) might possibly be more reliable, but I've used Inet (with either GetChunk or OpenURL) with success.
Hi, thanks by your reply, I also too used Execute/GetChunk, and that was the result that I got.

But, since I investigate a bit, after years using the MSINET.OCX ripped off from (sp6 for vb6 files), it was v5.0.37.14, and navigating in this forum I found a entire thread of someone resolving that kind of problems just upgrading to the latest version that is like v6.1.x.xx or something, anyway 32KB bigger!.

I fastly implemented it yesteday, did the announce to the public and all we will start to test it, only over TIME will says if it did the difference.
Reply With Quote
  #4  
Old 08-19-2013, 04:12 PM
flyguille flyguille is offline
Newcomer
 
Join Date: Apr 2010
Location: Argentinia
Posts: 14
Default

Anyway, all these years using the msinet, I allways suspected about it having data losses, like having internal buffers problems, or incorrect handling of events.

I detect primarily 3 bugs in this OCX.

1) If you reads some value at the HTML header (using the related method/function), and this value does not exists, it will ERASE all the package received, like, you trying to read the filelength but the webbrowser just didn't provide this info for some files extensions, so when you attempt to read that, it will trash all the first package, corrupting the download.

The trick to solve this is to read all the entire HTML header, and use Instr() to lookup for the value, as always is something in the header, it will be safer always.

2) If somebody newbie with the control try to follow the GetChunk examples in the VB documents, it will always fail, not be able to download more than 50 to 80K from anywhere.

It is because If you don't inserts a DoEvents, in your code loop for getting all the chunks, you are not letting msinet to refill its internals buffers or something like that, if your file is tiny like 20 - 50K it won't be a problem, going far than that is impossible, unless magic.

3) It will be stable as it don't get too fast, or too high ping. It depends on the perfect reliability of the webserver.

Sure Microsoft addresses fixes to all these problems at some given point, I started with the msinet included in the vb5, then like in 2009 switched to the one in sp6 for vb6, now, thanks to this forum I found a newer version, and we are in the testing of "if something changed" testing stage. It worked directly with no recompile needed, so the upgrade is binary compatible.

Last edited by flyguille; 08-19-2013 at 04:19 PM.
Reply With Quote
  #5  
Old 08-20-2013, 07:15 AM
dilettante's Avatar
dilettanteis anything better than MSINET.OCX? dilettante is offline
Underclocked lifestyle

Forum Leader
* Guru *
 
Join Date: Feb 2005
Location: Michigan, USA
Posts: 4,524
Default

Strange, I have no problems downloading large resources.

Code:
Option Explicit

Private SaveFName As String
Private ContentLength As Long
Private ContentReceived As Long

Private Sub SetUI(ByVal Enabled As Boolean)
    Text1.Enabled = Enabled
    Text2.Enabled = Enabled
    Command1.Enabled = Enabled
End Sub

Private Sub Command1_Click()
    Dim URL As String
    
    URL = Trim$(Text1.Text)
    SaveFName = Trim$(Text2.Text)
    If Len(URL) > 0 And Len(SaveFName) > 0 Then
        SetUI False
        
        ContentLength = 0
        ContentReceived = 0
        Inet1.Execute URL, _
                      "GET", _
                      "Cache-Control: no-cache" & vbCrLf _
                    & "Pragma: no-cache" & vbCrLf
        lblStatus.Caption = "Started"
    Else
        Text1.SetFocus
    End If
End Sub

Private Function ProbeForContentLength() As Long
    'Returns 0, or Content-Length value if available.
    Dim Probe As String
    
    Probe = Inet1.GetHeader("Content-Length")
    If Len(Probe) > 0 Then
        If Not Probe Like "*[!0-9]*" Then
            ProbeForContentLength = CLng(Probe)
        End If
    End If
End Function

Private Sub Inet1_StateChanged(ByVal State As Integer)
    Const DefaultMaxChunk As Long = 65536
    Dim SaveF As Integer
    Dim Chunk() As Byte
    Dim ChunkSize As Long
    
    Select Case State
        Case icResponseReceived
            'There is never any reason to expect data (content) to
            'be available at this point.  At best the receive
            'header processing may be complete.
            
            'Optional early header-fetch attempt for Content-Length.
            'Not especially useful for any practical purpose.
            If ContentLength = 0 Then
                ContentLength = ProbeForContentLength()
                If ContentLength <> 0 Then
                    lblStatus.Caption = "Length " _
                                      & Format$(ContentLength, "#,##0")
                End If
            End If
            
        Case icResponseCompleted
            'Header-fetch attempt for Content-Length, which may not
            'have been returned by the server at all.  This is actually
            'pointless since the only thing it allows us to do is try
            'to gulp in one go.
            '
            'Even that may fail if we retrieve the data as String
            'characters:
            '
            'Content-length is in octets, but a String GetChunk() call
            'translates from the response's Content-Type header's
            'character encoding which might be a multi-byte encoding
            'such as UTF-8.
            '
            'Content-Length is only a character count in the most
            'trivial cases (ASCII/ANSI encodings).
            If ContentLength = 0 Then ContentLength = ProbeForContentLength()
        
            On Error Resume Next
            Kill SaveFName
            On Error GoTo 0
            
            SaveF = FreeFile(0)
            Open SaveFName For Binary Access Write As #SaveF
            
            If ContentLength > 0 Then
                'We can get it all in one go.  The reason to avoid doing this
                'is that in many cases we may have a huge amount of data,
                'which is already eating up a lot of memory in the buffer.
                'By doing this we double the memory we're using!
                '
                'Thus there is normally no reason to get Content-Length at
                'all since it does you no real good.
                Chunk = Inet1.GetChunk(ContentLength, icByteArray)
                Put #SaveF, , Chunk
                ContentReceived = ContentLength
            Else
                'This is the preferred way to copy and use the buffered
                'data.
                '
                'No idea how much data we have, so grab it in chunks
                'of arbitrary size until no more data.
                Do
                    Chunk = Inet1.GetChunk(DefaultMaxChunk, icByteArray)
                    ChunkSize = UBound(Chunk) + 1
                    If ChunkSize > 0 Then
                        Put #SaveF, , Chunk
                        ContentReceived = ContentReceived + ChunkSize
                    End If
                Loop Until ChunkSize = 0
            End If
            Close #SaveF
            lblStatus.Caption = "Finished, " _
                              & Format$(ContentReceived, "#,##0") _
                              & " bytes received and written"
            SetUI True
        
        Case icError
            Close #SaveF
            Kill SaveFName
            lblStatus.Caption = "Error: " _
                              & CStr(Inet1.ResponseCode) _
                              & " " & Inet1.ResponseInfo
            SetUI True
    End Select
End Sub
Works consistently for small or large resources, though I didn't actually test this code with any download larger than 8MB.

No errrors, no data loss, and no DoEvents calls.

Attached VB6 demo Project.
Attached Files
File Type: zip INet Download.zip (3.0 KB, 37 views)
Reply With Quote
  #6  
Old 08-20-2013, 10:29 AM
flyguille flyguille is offline
Newcomer
 
Join Date: Apr 2010
Location: Argentinia
Posts: 14
Default

Quote:
Inet1.GetHeader("Content-Length")
seems like you already used always a msinet.ocx with the "erases all the chunk if Content-Length" isn't provided bug. And maybe it has fixed the DoEvents thing.
Reply With Quote
  #7  
Old 08-20-2013, 10:32 AM
flyguille flyguille is offline
Newcomer
 
Join Date: Apr 2010
Location: Argentinia
Posts: 14
Default

just for sharing, this is the actual code I uses.

Code:
Private Sub Internet_StateChanged(ByVal State As Integer)
Dim tempArray() As Byte
Dim filesize As Long
Dim transferred As Long, H As String
Dim vtData As Variant
Dim LabelCaption As String
' Hay novedades en el servicio de descargas desde internet.

Select Case State
Case icError
    ' Devolvió un error en la operación actual.
    WARNING_NO_NEW_DOWNLOAD = True
    Call SetInternetFileFail
    WARNING_NO_NEW_DOWNLOAD = False
Case icResponseCompleted
    ' Recibe datos del archivo que el sistema caché de internet está bajando actualmente.
    WARNING_NO_NEW_DOWNLOAD = True
    LabelCaption = LabelProgress.Caption
    On Error GoTo Err
    ' Para saber el tamaño del fichero en bytes.
    H = Internet.GetHeader()
    If InStr(1, H, "Content-Length", vbTextCompare) Then
        ' Existe la declaración de longitud.
        ' Extrae el tamaño del archivo.
        filesize = Internet.GetHeader("Content-Length")
    Else
        filesize = -1
    End If
    ' Limpia al archivo destino.
    On Error Resume Next
    Kill App.Path + "\" + TempFileName
    On Error GoTo Err
    ' Creamos y abrimos un nuevo archivo en modo binario.
    Open App.Path + "\" + TempFileName For Binary As #FileDownload

    ' Leemos de a 1 Kbytes. El segundo parámetro indica _
      el tipo de fichero. Tipo texto o tipo Binario, en este caso binario.
    vtData = Internet.GetChunk(1024, icByteArray)
    
    DoEvents

    Do While Len(vtData)
        ' Almacenamos en un array el contenido del archivo que se va leyendo.
        tempArray = vtData
        ' Escribimos los datos en el archivo.
        Put #FileDownload, , tempArray
        ' Actualiza visor de progreso.
        If filesize >= 0 Then
            ' Conoce el tamaño.
            LabelProgress.Caption = LabelCaption + " %" + Trim$(Str$(Int((LOF(FileDownload) / filesize) * 100))) + " completo."
        Else
            ' No conoce el tamaño.
            transferred = transferred + Len(vtData)
            LabelProgress.Caption = LabelCaption + " " + Trim$(Str$(transferred)) + "bytes descargados."
        End If
        ' Leemos datos de a 1KB.
        vtData = Internet.GetChunk(1024, icByteArray)

        DoEvents
    Loop

    Close #FileDownload
    
    ' Verifica que el archivo esté bajado completo.
    If filesize = FileLen(App.Path + "\" + TempFileName) Or filesize = -1 Then
        ' Indicar éxito.
        Call SetInternetFileSucess
    Else
        ' Indicar fracaso.
        Call SetInternetFileFail
    End If
    
    WARNING_NO_NEW_DOWNLOAD = False
End Select

Exit Sub

Err:
Resume Err2
Err2:
Close #FileDownload
' Devolvió un error en la operación actual.
Call SetInternetFileFail
WARNING_NO_NEW_DOWNLOAD = False

End Sub
Notes:

WARNING_NO_NEW_DOWNLOAD = True

It is an indication for the rest of the installer not to try the next file to downloads because currently is one downloading, Why?

Because something too basic like "If Internet.StillExecuting = False Then", fails sometimes it returns false status data, I thinks it has to do about inserting the DoEvents, but without the DoEvents, is was unable to download more than 50 to 80KB, unless magic (like step by step execution, that giveme the clue that there must be a DoEvents ).

So, in the timer event that is looking for executing the next download has:

Code:
    If WARNING_NO_NEW_DOWNLOAD = False Then
        ' Verifica si está disponible el servicio de descarga.
        If Internet.StillExecuting = False Then
            ' Está disponible el servicio de descarga.
...
Internet.Execute "http
...

Last edited by flyguille; 08-20-2013 at 10:40 AM.
Reply With Quote
  #8  
Old 08-20-2013, 10:36 AM
dilettante's Avatar
dilettanteis anything better than MSINET.OCX? dilettante is offline
Underclocked lifestyle

Forum Leader
* Guru *
 
Join Date: Feb 2005
Location: Michigan, USA
Posts: 4,524
Default

My example doesn't "erase" any chunks.

What it does is retrieve data from the buffer in chunks unless it found a valid Content-Length header. It shouldn't even do it then, since retrieval based on Content-Length is problematic in the case of text and in general wastes memory for large resources (files).

There isn'y any bug in the INet control as far as I can see, more likely you have program bugs (using the control incorrectly).
Reply With Quote
  #9  
Old 08-20-2013, 10:42 AM
flyguille flyguille is offline
Newcomer
 
Join Date: Apr 2010
Location: Argentinia
Posts: 14
Default

Quote:
Originally Posted by dilettante View Post
My example doesn't "erase" any chunks.

What it does is retrieve data from the buffer in chunks unless it found a valid Content-Length header. It shouldn't even do it then, since retrieval based on Content-Length is problematic in the case of text and in general wastes memory for large resources (files).

There isn'y any bug in the INet control as far as I can see, more likely you have program bugs (using the control incorrectly).
uses v5.0.37.14 and you will see (or the native from vb5).
Reply With Quote
  #10  
Old 08-20-2013, 10:48 AM
dilettante's Avatar
dilettanteis anything better than MSINET.OCX? dilettante is offline
Underclocked lifestyle

Forum Leader
* Guru *
 
Join Date: Feb 2005
Location: Michigan, USA
Posts: 4,524
Default

Your code is full of nasty things.

Code:
LabelProgress.Caption = LabelCaption + " " + Trim$(Str$(transferred)) + "bytes descargados."
Do not use "+" for concatenation. Use "&" always.

Trim$(Str$(transferred)) is just goofy, use CStr(transferred)

Code:
Do While Len(vtData)
There is no reason to use a Variant here, it will only cost you performance. Yes, the ancient examples in the documentation suggest this but that's because they are poor, leftover examples dating back to VB4.

The test above uses Len() which doesn't work on a Byte array, so you are telling VB to "create a String from the bytes in vtData and then measure the length of that."

Get rid of the Variant, use a Byte array, and use UBound() and add 1 to the result.


Your attempt to show "progress" is a failure since by the time Status = icResponseCompleted 100% of the data has already been received. All your "progress" shows is the "progress" writing to disk. Are you writing floppies or something else terribly slow???
Reply With Quote
  #11  
Old 08-20-2013, 10:50 AM
dilettante's Avatar
dilettanteis anything better than MSINET.OCX? dilettante is offline
Underclocked lifestyle

Forum Leader
* Guru *
 
Join Date: Feb 2005
Location: Michigan, USA
Posts: 4,524
Default

Quote:
Originally Posted by flyguille View Post
uses v5.0.37.14 and you will see (or the native from vb5).
Why would I do that?

VB5 was not even supported on Windows 95 machines anymore after IE 5.0 came out in 1999.
Reply With Quote
  #12  
Old 08-20-2013, 10:58 AM
flyguille flyguille is offline
Newcomer
 
Join Date: Apr 2010
Location: Argentinia
Posts: 14
Default

Quote:
Originally Posted by dilettante View Post
Why would I do that?

VB5 was not even supported on Windows 95 machines anymore after IE 5.0 came out in 1999.
Well, is what I have, VB5 for programming, and the OCXs ripped from sp6 / VB6.

It worked pretty ok for me except with msinet, oh, and with mswinsck so I ripped off from the SP6 for vb6 and all goes ok, (msinet with those tricks).

Anyway as upgraded the msinet two days ago to v6.1.x.x, maybe I already fixed all the stability problems, lets wait what the customers says.!
Reply With Quote
  #13  
Old 08-20-2013, 11:29 AM
dilettante's Avatar
dilettanteis anything better than MSINET.OCX? dilettante is offline
Underclocked lifestyle

Forum Leader
* Guru *
 
Join Date: Feb 2005
Location: Michigan, USA
Posts: 4,524
Default

Not only does your use of Len() fail on performance, it returns the wrong value!

Look at this small demo and the screenshots attched.

Code:
Option Explicit

Private Sub Main()
    Dim vBytes As Variant
    Dim Bytes() As Byte
    Dim I As Long
    Dim BytesLength As Long
    Dim vBytesLength As Long
    
    ReDim Bytes(50000 - 1)
    vBytes = Bytes
    
    For I = 1 To 100000
        BytesLength = UBound(Bytes) + 1
        vBytesLength = Len(vBytes)
    Next
    
    MsgBox "BytesLength = " & CStr(BytesLength) & vbNewLine _
         & "vBytesLength = " & CStr(vBytesLength)
End Sub
Attached Images
File Type: png sshot1.png (8.2 KB, 2 views)
File Type: png sshot2.png (2.6 KB, 1 views)
Reply With Quote
  #14  
Old 08-20-2013, 11:39 AM
flyguille flyguille is offline
Newcomer
 
Join Date: Apr 2010
Location: Argentinia
Posts: 14
Default

Quote:
Originally Posted by dilettante View Post
Not only does your use of Len() fail on performance, it returns the wrong value!

Look at this small demo and the screenshots attched.

Code:
Option Explicit

Private Sub Main()
    Dim vBytes As Variant
    Dim Bytes() As Byte
    Dim I As Long
    Dim BytesLength As Long
    Dim vBytesLength As Long
    
    ReDim Bytes(50000 - 1)
    vBytes = Bytes
    
    For I = 1 To 100000
        BytesLength = UBound(Bytes) + 1
        vBytesLength = Len(vBytes)
    Next
    
    MsgBox "BytesLength = " & CStr(BytesLength) & vbNewLine _
         & "vBytesLength = " & CStr(vBytesLength)
End Sub
Ok, you are pointing me that the TEXT shown in the label as "#### bytes downloaded" is wrong, I didn't noticed that I will check LabelProgress.Caption is showing correctly the ammount of bytes, anyway, there is no other use of the value collected by len(Variant).

Unless the check "While len(Variant)" can fail somehow ?..... mmmm, how?, if that is true, it must fails for anybody always, and the reality that you can downloads hundres files without any fail if you are at argentinia, but if you are at mexico it sometimes retries and retries on large files.

"While len(Variant)" this is only checking if GetChunk did gets something or not, if not, it exits the loop. Can that simple true/false check fail?.

Thanks by pointing that.

Last edited by flyguille; 08-20-2013 at 11:47 AM.
Reply With Quote
  #15  
Old 08-20-2013, 12:34 PM
dilettante's Avatar
dilettanteis anything better than MSINET.OCX? dilettante is offline
Underclocked lifestyle

Forum Leader
* Guru *
 
Join Date: Feb 2005
Location: Michigan, USA
Posts: 4,524
Default

Quote:
Originally Posted by flyguille View Post
Unless the check "While len(Variant)" can fail somehow ?..... mmmm, how?, if that is true, it must fails for anybody always, and the reality that you can downloads hundres files without any fail if you are at argentinia, but if you are at mexico it sometimes retries and retries on large files.

"While len(Variant)" this is only checking if GetChunk did gets something or not, if not, it exits the loop. Can that simple true/false check fail?.
The check should not fail, but that doesn't make it right. The point is that your code to do that check can take as much as 200 times as long as doing it correctly.

It also returns the wrong value, half the real value. This is another reason to stop doing this because sooner or later it is going to matter, and may even be why you have "lost data" in the past.
Reply With Quote
  #16  
Old 08-20-2013, 12:53 PM
flyguille flyguille is offline
Newcomer
 
Join Date: Apr 2010
Location: Argentinia
Posts: 14
Default

Quote:
Originally Posted by dilettante View Post
The check should not fail, but that doesn't make it right. The point is that your code to do that check can take as much as 200 times as long as doing it correctly.

It also returns the wrong value, half the real value. This is another reason to stop doing this because sooner or later it is going to matter, and may even be why you have "lost data" in the past.
Ah, now I understand why I didn't notice, because most of time the webserver transmits "ContentLenght" for like 99% of files to download, and when the installer has that information it don't use the LEN(Variant) at all for counting length, it uses LOF(filenumer) / knownfilelength and shows a percentage. Only for very little .dat files, the webserver don't sends that value and only that way it counts and shows "#### bytes downloaded".

Now about Len() vs Ubound(), I was not sure (at that time) if the Getchunk returns nothing or returns an empty array, if you try Ubound with Variant = nothing it generates an Error. So, the feels was Len() was safer. Anyway is only testing if there is DATA or NOT, ZERO or NOT.

What about using LenB()?.
Reply With Quote
  #17  
Old 08-20-2013, 06:49 PM
dilettante's Avatar
dilettanteis anything better than MSINET.OCX? dilettante is offline
Underclocked lifestyle

Forum Leader
* Guru *
 
Join Date: Feb 2005
Location: Michigan, USA
Posts: 4,524
Default

LenB() might give you the right size value, but it still involves very expensive conversion and copying.
Reply With Quote
  #18  
Old 08-20-2013, 07:13 PM
flyguille flyguille is offline
Newcomer
 
Join Date: Apr 2010
Location: Argentinia
Posts: 14
Default

Quote:
Originally Posted by dilettante View Post
LenB() might give you the right size value, but it still involves very expensive conversion and copying.
"very expensive conversion" sounds like you are saying that it does a cast or (maybe worst duplicating it in memory) to a string datatype or something like that?. Really?.

IIRC I readed that Lenb() just readed the length property of the BSTR struct that is just an indirect memory peek, while LEN() it returns the length assuming UNICODE/UTF16 always, so it returns the half of the real size in bytes. So that is why len() is just a bit slower than lenb() it does an extra division by 2. Now all this if the input is a String, if It a variant, it is not just an extra check for what datatype is hosting the variant?.

Now, I normaly, don't uses "Variant" variables at all in my code, except when there is no other way to do it, like the GetChunk function, I didn't find a way to use that function directly with a string variable or a byte array, I remember that tried a lot, but not.

So, that is the reason why that code looks like having redundants, one variant and one byte array, the variant for the GetChunk, the byte array for the file PUT.

Anyway, in your example it uses a bytearrays directly, so, I must to upgrade my code it is half efficient I see.

Thanks a lot by the help, but just for the lesson, can you telme if lenb(variant) does duplication in memory or just an logical extra check?

Last edited by flyguille; 08-20-2013 at 07:19 PM.
Reply With Quote
  #19  
Old 08-20-2013, 08:30 PM
dilettante's Avatar
dilettanteis anything better than MSINET.OCX? dilettante is offline
Underclocked lifestyle

Forum Leader
* Guru *
 
Join Date: Feb 2005
Location: Michigan, USA
Posts: 4,524
Default

Don't say "cast" since it isn't the same thing as conversion at all and almost never happens in a VB program. A cast tells the compiler "let's pretend this data is of another type" and conversion always says "make a new copy converted to another type."


Whether you use Len() or LenB() it must do the same thing: create a temporary Variant of the String subtype and then evaluate the length. This means making a copy of the entire Byte array inside the original Variant variable. Then this copy is just thrown away.

Even if you replace the Variant by a dynamic Byte array, calling Len()/LenB() still creates a temporary String copy of the entire block of data.


This I why I showed you the timings in the screen capture image above: Using Len() or LenB() takes 200 times as long as Ubound() + 1 for 50,000 bytes of data.
Reply With Quote
  #20  
Old 08-21-2013, 12:01 PM
flyguille flyguille is offline
Newcomer
 
Join Date: Apr 2010
Location: Argentinia
Posts: 14
Default

I just noticed in the example:

_
"Cache-Control: no-cache" & vbCrLf _
& "Pragma: no-cache" & vbCrLf

Great, this will saveme a lot of online support saying "just reset your cache and it will works".
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Advertisement:





Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe
is anything better than MSINET.OCX?
is anything better than MSINET.OCX?
is anything better than MSINET.OCX? is anything better than MSINET.OCX?
is anything better than MSINET.OCX?
is anything better than MSINET.OCX?
is anything better than MSINET.OCX? is anything better than MSINET.OCX? is anything better than MSINET.OCX? is anything better than MSINET.OCX? is anything better than MSINET.OCX? is anything better than MSINET.OCX? is anything better than MSINET.OCX?
is anything better than MSINET.OCX?
is anything better than MSINET.OCX?
 
is anything better than MSINET.OCX?
is anything better than MSINET.OCX?
 
-->