With VB 2008 something using the stream class

Posted on 2009-04-24
Last Modified: 2013-12-26
I am having trouble understanding how the stream can be read and data extracted to a fielded recordset.

Dim myStream As Stream = Nothing

        Dim openFileDialog1 As New OpenFileDialog()

        openFileDialog1.InitialDirectory = Application.StartupPath & \Data\

        openFileDialog1.Filter = "Icon files (*.ico|"

        openFileDialog1.FilterIndex = 2

        openFileDialog1.RestoreDirectory = True

        If openFileDialog1.ShowDialog() = System.Windows.Forms.DialogResult.OK Then


                myStream = openFileDialog1.OpenFile()

                If (myStream IsNot Nothing) Then

                    ' Insert code to read the stream here. Here is the 

                'something like this?

              mydate = read(buffer, 1, 16) 

                End If

            Catch Ex As Exception

                MessageBox.Show("Cannot read file from disk. Original error: " & Ex.Message)


                ' Check this again, since we need to make sure we didn't throw an exception on open.

                If (myStream IsNot Nothing) Then


                End If

            End Try

        End If

Open in new window

Question by:Jimmyjay21
    1 Comment
    LVL 85

    Accepted Solution

    You want to read the first 16 bytes?

                        Dim buffer(16) As Byte
                        myStream.Read(buffer, 0, buffer.Length)
                        ' do something with "buffer"...

    Featured Post

    IT, Stop Being Called Into Every Meeting

    Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

    Join & Write a Comment

    Introduction In a recent article ( for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
    This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
    Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
    Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

    734 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    26 Experts available now in Live!

    Get 1:1 Help Now