Quantcast
Channel: VBForums - Visual Basic .NET
Viewing all articles
Browse latest Browse all 27031

VS 2010 index was outside the bounds of the array error

$
0
0
Hello,
I'm a newbie program developer and i'm using visual studio 2010.
I got a problem named "index was outside the bounds of the array error"
I can't understand the problem..
Please help me..I'm giving the details below about the problems :


Actually i am trying to make a individual notepad program with mysqldatabase that contains a listbox where i want to show notepad titles and the other facilities belongs in code...
I have no problem with the code as i did for the contents but i can't resolve the problem of the above mentioned array problem.


Graphical snapshot:
Attachment 97777

Problem's snapshot:
Attachment 97773

The codes:
Code:

Imports MySql.Data.MySqlClient
Public Class yourNotes
    Public Listbox3 As New ListBox
    Public splitread() As String
    Private Sub yourNotes_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Dim conn As MySqlConnection
        conn = New MySqlConnection(ServerString)
        Dim command_n As New MySqlCommand
        Dim sqlquery_n As String = "SELECT * FROM off_members"
        Dim adapter As New MySqlDataAdapter
        Dim data As MySqlDataReader
        conn.Open()
        command_n.CommandText = sqlquery_n
        command_n.Connection = conn
        adapter.SelectCommand = command_n
        data = command_n.ExecuteReader
        While data.Read()
            notesList.Items.Add(data(16).ToString)
            Listbox3.Items.Add(data(1).ToString)
            Dim writer As New System.IO.StreamWriter(My.Application.Info.DirectoryPath + "/" + data(16).ToString + data(1).ToString + ".txt", False)
            writer.Write(data(1).ToString + "=" + data(16).ToString + "=" + data(17).ToString)
            writer.Close()
        End While
        data.Close()
        conn.Close()
    End Sub

    Private Sub notesList_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles notesList.SelectedIndexChanged
        Listbox3.SelectedIndex = notesList.SelectedIndex
        Dim reader As New System.IO.StreamReader(My.Application.Info.DirectoryPath + "/" + notesList.SelectedItem.ToString + Listbox3.SelectedItem.ToString + ".txt")
        splitread = reader.ReadToEnd.Split("=")
        reader.Close()
        lbl_title.Text = "Titile : " + splitread(16).ToString
        lbl_notes.Text = "Notes : " + splitread(17).ToString
    End Sub

    Private Sub cbx_editmode_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cbx_editmode.CheckedChanged
        If cbx_editmode.Checked = True Then
            'Edit Mode is enabled
            tbx_title.Visible = True
            tbx_notes.Visible = True
            lbl_title.Text = splitread(16).ToString
            lbl_notes.Text = splitread(17).ToString
            lbl_title.Text = "Titile : "
            lbl_notes.Text = "Notes : "
            btn_save.Visible = True
        Else
            'Edit Mode is disabled
            tbx_title.Visible = False
            tbx_notes.Visible = False
            lbl_title.Text = "Titile : " + splitread(16).ToString
            lbl_notes.Text = "Notes : " + splitread(17).ToString
            btn_save.Visible = False
        End If
    End Sub

    Private Sub btn_save_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn_save.Click
        Dim conn As MySqlConnection
        conn = New MySqlConnection(ServerString)
        Dim command_n As New MySqlCommand
        Dim sqlquery_n As String = "UPDATE off_members SET Title_notes='" & tbx_title.Text & "', Notes='" & tbx_notes.Text & "' WHERE Title_notes='" & notesList.SelectedItem & "';"
        Dim adapter As New MySqlDataAdapter
        Dim data As MySqlDataReader
        conn.Open()
        command_n.CommandText = sqlquery_n
        command_n.Connection = conn
        adapter.SelectCommand = command_n
        data = command_n.ExecuteReader

        data.Close()
        conn.Close()
        Me.Close()
        Dim yourNotes As New yourNotes
        yourNotes.show()
    End Sub
End Class

Please help me to solve this problem as soon as possible !

Thanks in advance !!
Attached Images
 

Viewing all articles
Browse latest Browse all 27031

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>