Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Visual Basic
  4. make sure that the max index on a list is less than the list size

make sure that the max index on a list is less than the list size

Scheduled Pinned Locked Moved Visual Basic
helpcsharpcssdatabasesecurity
3 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • Z Offline
    Z Offline
    zaimah
    wrote on last edited by
    #1

    hi, iv got this prgm where i choose a file, read the data in the file, compare it with a directory whether data in that file r in that directory.. data in the file 20090101 C1234 B0018 20090211 C1234 B0150 20090228 C5678 BRT10 20090228 C5678 BP001 when i debug the prgm, the error happen in convertCoop(coop) at Catch Ex As Exception.. b4 Catch part, the value of coop can be retrieve, but when i try to put values from table kodPortal to portal that is portal = ds.Tables(0).Rows(0).Item("portal"), at this part, no values are enter to portal. the error at catch is "make sure that the max index on a list is less than the list size". before this the prgm can run and come out with an output, but when i choose file that have no extension, the error come out.. after i did some editing, now any file that i choose have the same error. Pls help me... i have been posting this msg at several forum, but no one can help me..

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

        Dim fdlg As OpenFileDialog = New OpenFileDialog()
        fdlg.Title = "C# Corner Open File Dialog"
        fdlg.InitialDirectory = "c:\\"
        fdlg.Filter = "All files (\*.\*)|\*.\*|All files (\*.\*)|\*.\*"
        fdlg.FilterIndex = 2
        fdlg.RestoreDirectory = True
    
        If fdlg.ShowDialog() = Windows.Forms.DialogResult.OK Then
            TextBox1.Text = fdlg.FileName
        End If
    
    
    
    
    End Sub
    

    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click

        Dim folderopen As New FolderBrowserDialog
        With folderopen
            .RootFolder = Environment.SpecialFolder.Desktop
            .SelectedPath = "C:\\DOCUMENT"
            .Description = "Select the source directory"
            If .ShowDialog = Windows.Forms.DialogResult.OK Then
                ' Display the selected folder if the user clicked on the OK button.
                MessageBox.Show(.SelectedPath)
                TextBox2.Text = .SelectedPath
            End If
    
        End With
    End Sub
    

    Private Sub convertCoop(ByVal coop As String)

        Dim conn1 As New SqlClient.SqlConnection("Data Source=10.0.0.70;User ID= sysadm;Password=sysadm;Initial Catalog=SPGA\_Latihan;Persist Security Info=True;")
        Dim comm As SqlClient.SqlDataAdapter = Nothing
        Dim ds As DataSet = New DataSet()
        Dim strSQL2 As String = "SELECT folder, portal FROM kod
    
    C 1 Reply Last reply
    0
    • Z zaimah

      hi, iv got this prgm where i choose a file, read the data in the file, compare it with a directory whether data in that file r in that directory.. data in the file 20090101 C1234 B0018 20090211 C1234 B0150 20090228 C5678 BRT10 20090228 C5678 BP001 when i debug the prgm, the error happen in convertCoop(coop) at Catch Ex As Exception.. b4 Catch part, the value of coop can be retrieve, but when i try to put values from table kodPortal to portal that is portal = ds.Tables(0).Rows(0).Item("portal"), at this part, no values are enter to portal. the error at catch is "make sure that the max index on a list is less than the list size". before this the prgm can run and come out with an output, but when i choose file that have no extension, the error come out.. after i did some editing, now any file that i choose have the same error. Pls help me... i have been posting this msg at several forum, but no one can help me..

      Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

          Dim fdlg As OpenFileDialog = New OpenFileDialog()
          fdlg.Title = "C# Corner Open File Dialog"
          fdlg.InitialDirectory = "c:\\"
          fdlg.Filter = "All files (\*.\*)|\*.\*|All files (\*.\*)|\*.\*"
          fdlg.FilterIndex = 2
          fdlg.RestoreDirectory = True
      
          If fdlg.ShowDialog() = Windows.Forms.DialogResult.OK Then
              TextBox1.Text = fdlg.FileName
          End If
      
      
      
      
      End Sub
      

      Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click

          Dim folderopen As New FolderBrowserDialog
          With folderopen
              .RootFolder = Environment.SpecialFolder.Desktop
              .SelectedPath = "C:\\DOCUMENT"
              .Description = "Select the source directory"
              If .ShowDialog = Windows.Forms.DialogResult.OK Then
                  ' Display the selected folder if the user clicked on the OK button.
                  MessageBox.Show(.SelectedPath)
                  TextBox2.Text = .SelectedPath
              End If
      
          End With
      End Sub
      

      Private Sub convertCoop(ByVal coop As String)

          Dim conn1 As New SqlClient.SqlConnection("Data Source=10.0.0.70;User ID= sysadm;Password=sysadm;Initial Catalog=SPGA\_Latihan;Persist Security Info=True;")
          Dim comm As SqlClient.SqlDataAdapter = Nothing
          Dim ds As DataSet = New DataSet()
          Dim strSQL2 As String = "SELECT folder, portal FROM kod
      
      C Offline
      C Offline
      Christian Graus
      wrote on last edited by
      #2

      I've answered you plenty of times. Your code sucks. Also, no-one is going to read this much code. Your core issues are: 1 - you read from a collection without checking first if it has objects at the index you specify 2 - this means your SQL is failing. #2 is the issue you need to resolve. #1 is just a matter of writing production quality code.

      Christian Graus Driven to the arms of OSX by Vista.

      Z 1 Reply Last reply
      0
      • C Christian Graus

        I've answered you plenty of times. Your code sucks. Also, no-one is going to read this much code. Your core issues are: 1 - you read from a collection without checking first if it has objects at the index you specify 2 - this means your SQL is failing. #2 is the issue you need to resolve. #1 is just a matter of writing production quality code.

        Christian Graus Driven to the arms of OSX by Vista.

        Z Offline
        Z Offline
        zaimah
        wrote on last edited by
        #3

        i know my code sucks bcoz this is my 2nd time doing a prgm n b4 this i dont even know how to use vb or vb.net at all. it would be great if u give me any related article regarding issues 1 n 2. as i said b4 in my previous post (not this one but the same problem) my english r not that good, so whenever i try to google my problem, i cannot find any related article to my problem. i know u dont have time to entertain my stupid question, but if u can pls give the related link. im quite confused why it run ok n suddenly it cannot bcoz i didnt do any editing on ds.table part and it can retrieve data from table b4 this. tq

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups