Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to copy the data from file to array in VB
    primarykey
    data
    text
    <p>I am pasting code ..which I am able to read file and but not able to put into array there is runtime error I am getting.I have made line bold where i am getting error.Anyone help me out I am quite new to VB.</p> <pre><code>Imports System.Drawing.Imaging Imports System.Runtime.InteropServices Imports System.IO Imports System.IO.Compression Public Class Form1 Private Sub Button1_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim openFileDialog1 As OpenFileDialog = New OpenFileDialog ' Set filter options and filter index. openFileDialog1.Filter = "BMP Files (*.bmp)|*.bmp|All Files (*.*)|*.*" openFileDialog1.FilterIndex = 1 openFileDialog1.Multiselect = True ' Call the ShowDialog method to show the dialogbox. Dim UserClickedOK As Boolean = openFileDialog1.ShowDialog PictureBox1.Image = Image.FromFile(openFileDialog1.FileName) Dim data() As Byte = File.ReadAllBytes(openFileDialog1.FileName) ' Dim hexval As String ' Dim objStreamWriter As StreamWriter Dim buff(data.Length()) As String Dim counter As Integer Dim Arr() As String = Nothing ' the file path and the file name to the StreamWriter constructor. ' objStreamWriter = New StreamWriter("C:\users \karmic\My Documents\Text.txt") 'Write a line of text. For i = LBound(data) To UBound(data) **Arr(i) = Hex(data(i))** -runtime error If i = data.Length() - 1 Then Continue For End If If (Hex(data(i))) = (Hex(data(i + 1))) Then counter = counter + 1 ' MsgBox(counter) Continue For Else 'objStreamWriter.Write(hexval) 'MsgBox(hexval) ' Array.Copy(hexval, Arr(i), data.Length) 'objStreamWriter.Write(", ") 'objStreamWriter.Write(Hex(counter + 1)) MsgBox(Hex(counter + 1)) 'objStreamWriter.Write(", ") End If 'MsgBox(Array.Length()) Next End Sub End Class </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload